[RViz2] An error is reported when importing the urdf model: Could not load resource xxx, Unable to open file xxx, Error retrieving file xxx

Project scenario:

Beginner ROS2, want to display urdf model in RViz2. The .urdf file references the external meshes folder.
insert image description here
insert image description here


Problem Description

After accessing the robot description topic in RViz, the following error occurs
insert image description here


Cause Analysis:

According to the error description, it should be that the files in the meshes have not been correctly imported into the environment variables.
Check whether the meshes file in the install/pkg/share folder is displayed correctly under the workspace.
It was found that the visual and collision folders did not exist.
Therefore, we need to modify the setup.py file to include it correctly.


solution:

The mesh import in the urdf file should use the following format:

<mesh filename="package://webots_ros2_ur_demo/meshes/visual/base.dae"/>

rather than <mesh filename="file://$(find ur5_pick_and_place)/meshes/visual/base.dae"/>a format such as .

Amend the setup.py file to add the following to the data_files parameter:

	('share/' + package_name + '/meshes/visual', [
        'meshes/visual/base.dae',
        'meshes/visual/forearm.dae',
        'meshes/visual/shoulder.dae',
        'meshes/visual/upperarm.dae',
        'meshes/visual/wrist1.dae',
        'meshes/visual/wrist2.dae',
        'meshes/visual/wrist3.dae',
    ]),
    ('share/' + package_name + '/meshes/collision', [
        'meshes/collision/base.stl',
        'meshes/collision/forearm.stl',
        'meshes/collision/shoulder.stl',
        'meshes/collision/upperarm.stl',
        'meshes/collision/wrist1.stl',
        'meshes/collision/wrist2.stl',
        'meshes/collision/wrist3.stl',
    ]),

The result is as follows:
insert image description here

Guess you like

Origin blog.csdn.net/qq_43557907/article/details/125869467