ros-simulation / gazebo_ros_pkgs

Wrappers, tools and additional API's for using ROS with Gazebo
http://wiki.ros.org/gazebo_ros_pkgs
742 stars 766 forks source link

[ros2] gazebo_ros_path plugin paths are annoying #1500

Open DLu opened 11 months ago

DLu commented 11 months ago

Rant

In order to get meshes from URDF, the URDF package must export a very specific value.

    <gazebo_ros gazebo_model_path="${prefix}/.."/>

What the export does is specify a proper value of the GAZEBO_MODEL_PATH environment variable. If you say that your model path includes /home/user/models and you try to load an SDF (or other resource) with the syntax model://robot_name/file.ext, then it will enable you to load a file with the path /home/user/models/robot_name/file.ext. Logical so far...

The value of ${prefix} in your package.xml is the path to the ROS package's share folder. For instance, if you're compiling from source, that might be

/home/user/ros2_ws/install/package_name/share/package_name/

So if you specify the mesh with the syntax package://package_name/meshes/file.ext it will presumably be installed at

${prefix}/meshes/file.ext

or

/home/user/ros2_ws/install/package_name/share/package_name/meshes/file.ext

However, if we say that the Gazebo model path is ${prefix} it will attempt to load package://package_name/meshes/file.ext as

${prefix}/package_name/meshes/file.ext

or

/home/user/ros2_ws/install/package_name/share/package_name/package_name/meshes/file.ext

Note that package_name appears in there THREE times as opposed to the usual two.

Hence, we need to set the Gazebo model path to ${prefix}/.. which is surprisingly valid syntax and results in file being loaded as

${prefix}/../package_name/meshes/file.ext

or

/home/user/ros2_ws/install/package_name/share/package_name/meshes/file.ext