Skip to content

Commit abe4b16

Browse files
authored
folder structure, simulation assests and env hooks (#399)
Signed-off-by: Dharini Dutia <dharini@openrobotics.org>
1 parent d1cc55e commit abe4b16

File tree

2 files changed

+44
-6
lines changed

2 files changed

+44
-6
lines changed

harmonic/ros2_interop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Start a fresh ROS 2 Python launch file or add the following nodes in your projec
2020
1. A robot model development and test setup
2121
2. Configure RViz (and other ROS 2 tools) to control a robot model simulated by a Gazebo world
2222

23-
Note: The full source code for this tutorial can be found in the [ros_gz_example_brigup package](https://github.com/gazebosim/ros_gz_project_template/tree/main/ros_gz_example_bringup/launch) launch files.
23+
Note: The full source code for this tutorial can be found in the [ros_gz_example_bringup package](https://github.com/gazebosim/ros_gz_project_template/tree/main/ros_gz_example_bringup/launch) launch files.
2424

2525
## Implementation
2626

harmonic/ros_gz_project_template_guide.md

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,53 @@ In this guide, you will learn how to use the `ros_gz_project_template` to create
3232

3333
At this point you'll have the following packages in your project:
3434

35-
* `ros_gz_example_description` - holds the SDF description of the simulated system and any other simulation assets.
36-
Simulation assets means your models or robot descriptions in URDF or SDF, meshes and materials files to help visualize different parts of the robot and finally compiling all these elements in a simulated world SDF. Existing assets can be used by installing the models directory and exporting the paths to your environment.
37-
Setting up paths can be also automated using colcon environment hooks with a [DSV file](https://colcon.readthedocs.io/en/released/developer/environment.html?highlight=dsv#dsv-files) prepending the model share path to Gazebo resource path.
35+
* `ros_gz_example_application` - holds ROS 2 specific code and configurations. Namely where control, planning or any high level algoritms reside.
36+
37+
<pre> ├── CMakeLists.txt
38+
├── package.xml
39+
├── <span style="color:#12488B"><b>src</b></span>
40+
└── ...
41+
</pre>
42+
43+
* `ros_gz_example_bringup` - holds launch files and high level utilities, communication bridge between ROS and Gazebo. Any robot or hardware specific configurations go here.
44+
45+
<pre> ├── <span style="color:#12488B"><b>config</b></span>
46+
│   ├── ros_gz_example_bridge.yaml
47+
│   └── diff_drive.rviz
48+
├── <span style="color:#12488B"><b>launch</b></span>
49+
   └── diff_drive.launch.py
50+
</pre>
51+
52+
* `ros_gz_example_description` - holds the SDF description of the simulated system and any other [simulation assets](#accessing-simulation-assets).
53+
54+
<pre> ├── <span style="color:#12488B"><b>hooks</b></span>
55+
│   └── ros_gz_example_description.dsv.in
56+
├── <span style="color:#12488B"><b>models</b></span>
57+
   ├── <span style="color:#12488B"><b>diff_drive</b></span>
58+
      ├── model.config
59+
      └── model.sdf
60+
</pre>
3861

3962
* `ros_gz_example_gazebo` - holds Gazebo specific code and configurations. Namely this is where user-defined worlds and custom system plugins end up.
4063

41-
* `ros_gz_example_application` - holds ROS 2 specific code and configurations. Namely where control, planning or any high level algoritms reside.
64+
<pre> ├── <span style="color:#12488B"><b>include</b></span>
65+
│   └── <span style="color:#12488B"><b>ros_gz_example_gazebo</b></span>
66+
│   ├── BasicSystem.hh
67+
│   └── FullSystem.hh
68+
├── <span style="color:#12488B"><b>src</b></span>
69+
│   ├── BasicSystem.cc
70+
│   └── FullSystem.cc
71+
├── <span style="color:#12488B"><b>worlds</b></span>
72+
   └── diff_drive.sdf
73+
</pre>
4274

43-
* `ros_gz_example_bringup` - holds launch files and high level utilities, communication bridge between ROS and Gazebo. Any robot or hardware specific configurations go here.
75+
## Accessing Simulation Assets
76+
77+
Simulation assets include your models or robot descriptions in URDF or SDF, meshes and materials files to help visualize different parts of the robot and finally compiling all these elements in a simulated world SDF. Gazebo offers a few different mechanisms for locating those, initializing it's search on `GZ_SIM_RESOURCE_PATH` environment variable, see gz-sim API on [finding resources](https://gazebosim.org/api/sim/8/resources.html) for more details.
78+
79+
There is a difference in how ROS and Gazebo resolves URIs, that the ROS side can handle `package://` URIs, but by default SDFormat only supports `model://`. Now `libsdformat` can convert `package://` to `model://` URIs. So existing simulation assets can be loaded by "installing" the models directory and exporting the model paths to your environment.
80+
81+
This can be automated using colcon environment hooks (shell scripts provided by a ROS package) in a [DSV file](https://colcon.readthedocs.io/en/released/developer/environment.html?highlight=dsv#dsv-files). Whenever you source the setup file in a workspace these environment hooks are also being sourced. See an [example](https://github.com/gazebosim/ros_gz_project_template/blob/main/ros_gz_example_gazebo/hooks/ros_gz_example_gazebo.dsv.in) of prepending the model share path to `GZ_SIM_RESOURCE_PATH` which enables Gazebo to load models from a ROS package using the `model://` URI.
4482

4583
## Development
4684

0 commit comments

Comments
 (0)