ROS2 URDF Mesh Import from Outside Package


I encountered an issue with urdf-importer when importing a URDF designed to work with ROS2-Humble. A mesh from a ROS2 package is unable to be imported.

The error was being caused by the package path (ROS_PACKAGE_PATH) not being set. After sourcing my ROS2 workspace, this variable is not set. The closest equivalent is AMENT_PREFIX_PATH. After setting ROS_PACKAGE_PATH to be equal to AMENT_PREFIX_PATH, I was still unable to load the mesh.

The error was as follows:

Path: package://package_name/meshes/box.STL not found

The analogous line in the URDF file is:

<mesh filename="package://package_name/meshes/box.STL"/>

I was able to solve this issue by changing the line in the URDF file to:

<mesh filename="package://share/package_name/meshes/box.STL"/>

I am not sure what to make of this. Is there an option in the urdf-importer to handle ROS2 packages? I.e. make it look at AMENT_PREFIX_PATH by default and look within the share folder?

Thank you,