Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain how Gazebo and RViz can resolve mesh URIs (#26) #29

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions sdformat_urdf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,17 @@ The warning is issued using an `rcutils` logger with the name `sdformat_urdf`.
* The model should not disable dynamic lighting using the `<lighting>`
* The model should not use materials with `<script>`, `<shader>`, or `<pbr>`
* The URDF material name assigned the name of the SDFormat `<visual>` containing the material, so `<visual>` names should be unique within the model

### Considerations for Mesh URIs

The `model://` prefix is commonly used in SDFormat XML files to set URIs for meshes, e.g. `model://my_model/meshes/mesh1.obj`.
However, ROS tools likes `RViz` which rely on [resource_retriever](https://github.com/ros/resource_retriever/tree/ros2) will throw errors when attempting to load
a mesh from such an URI since `resource_retriever` does not resolve `model://` prefixes to absolute filepaths.
This may happen when an SDFormat XML file is parsed into an URDF XML by a `robot_state_publisher` node and published as a serialized
string over `/robot_description` which is subscribed to by `RViz`.
To allow both `Gazebo` and `RViz` to resolve URIs to absolute paths and load meshes properly, the following pattern may be adopted.
- Move the `my_model` folder containing the meshes, `model.sdf` and `model.config` files into a ROS package, say `my_model_description` which installs the model.
- Set the mesh URIs using the `package://` prefix, e.g. `package://my_model_description/models/my_model/meshes/mesh1.obj`
- Set the `GZ_SIM_RESOURCE_PATH` environment variable to `<install_prefix>/my_model_description/share/`.

> Note `<install_prefix>/my_model_description/share/` above is the output of `os.path.join(get_package_prefix('my_model_description'), 'share')` or `"$(ros2 pkg prefix my_model_description)/share"` and not `ros2 pkg prefix --share my_model_description` since the latter includes an extra package name at the end. See https://github.com/ros/sdformat_urdf/pull/20#issuecomment-1944430224 for more details.
Loading