Skip to content

Commit 1b0018c

Browse files
authored
Updating ros_gz documentation related to composition. (#526)
Signed-off-by: Carlos Agüero <[email protected]>
1 parent 1ac1547 commit 1b0018c

File tree

4 files changed

+43
-16
lines changed

4 files changed

+43
-16
lines changed

harmonic/ros2_integration.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,21 @@ The package `ros_gz_bridge` contains a launch file named
6767
`ros_gz_bridge.launch.py`. You can use it to start a ROS 2 and Gazebo bridge.
6868
Here's an example:
6969

70-
Note: If you run the bridge as a standalone node with composition enabled (default configuration),
70+
Note: If you run the bridge as a standalone node with composition enabled,
7171
you'll need to create a container first.
7272
```bash
7373
ros2 run rclcpp_components component_container --ros-args -r __node:=ros_gz_container
7474
```
7575

76+
Alternatively, if an existing container is already running, you can pass its name
77+
when launching the bridge using the `container_name` parameter.
78+
7679
And now, the container will load your bridge with:
7780
```bash
78-
ros2 launch ros_gz_bridge ros_gz_bridge.launch.py bridge_name:=ros_gz_bridge config_file:=<path_to_your_YAML_file>
81+
ros2 launch ros_gz_bridge ros_gz_bridge.launch.py bridge_name:=ros_gz_bridge use_composition:=True config_file:=<path_to_your_YAML_file>
7982
```
8083

81-
Check [this block](https://github.com/gazebosim/ros_gz/blob/jazzy/ros_gz_bridge/launch/ros_gz_bridge.launch.py#L27-L33)
84+
Check [this block](https://github.com/gazebosim/ros_gz/blob/jazzy/ros_gz_bridge/launch/ros_gz_bridge.launch.py#L27-L34)
8285
from the source code to know all the different parameters accepted by this
8386
launch file.
8487

@@ -94,21 +97,22 @@ within this tag. Here's an example:
9497
<arg name="bridge_name" />
9598
<arg name="config_file" />
9699
<arg name="container_name" default="ros_gz_container" />
100+
<arg name="create_own_container" default="False" />
97101
<arg name="namespace" default="" />
98-
<arg name="use_composition" default="True" />
102+
<arg name="use_composition" default="False" />
99103
<arg name="use_respawn" default="False" />
100104
<arg name="log_level" default="info" />
101105
<ros_gz_bridge
102106
bridge_name="$(var bridge_name)"
103107
config_file="$(var config_file)"
104108
container_name="$(var container_name)"
109+
create_own_container="$(var create_own_container)"
105110
namespace="$(var namespace)"
106111
use_composition="$(var use_composition)"
107112
use_respawn="$(var use_respawn)"
108113
log_level="$(var log_level)">
109114
</ros_gz_bridge>
110115
</launch>
111-
112116
```
113117

114118
In this case the `<ros_gz_bridge>` parameters are read from the command line.

harmonic/ros2_launch_gazebo.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ within this tag. Here's an example for launching Gazebo server:
3737
<arg name="world_sdf_file" default="empty.sdf" />
3838
<arg name="world_sdf_string" default="" />
3939
<arg name="container_name" default="ros_gz_container" />
40-
<arg name="use_composition" default="True" />
40+
<arg name="create_own_container" default="False" />
41+
<arg name="use_composition" default="False" />
4142
<gz_server
4243
world_sdf_file="$(var world_sdf_file)"
4344
world_sdf_string="$(var world_sdf_string)"
4445
container_name="$(var container_name)"
46+
create_own_container="$(var create_own_container)"
4547
use_composition="$(var use_composition)">
4648
</gz_server>
4749
</launch>

harmonic/ros2_overview.md

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,37 @@ We'll backport it to ROS 2 Jazzy soon.
3232
## Composition
3333

3434
If you inspect the parameters of the launch files mentioned in the next
35-
tutorials, you'll notice that we have included in most cases a parameter named
36-
`use_composition`. When that parameter is set to `True`, the associated ROS
37-
node will be included within a ROS container. When this happens all the nodes
38-
live within the same process and can leverage intraprocess communication.
39-
40-
Our recommendation is to always set the `use_composition` parameter to `True`.
41-
That way, the communication between Gazebo and the bridge will be intraprocess.
42-
If your ROS nodes are also written as composable nodes, make sure that they are
43-
launched with the `container_node_name` parameter matching the container name
44-
including Gazebo and the bridge.
35+
tutorials, you'll notice that we have included in most cases two parameters
36+
named `use_composition` and `create_own_container`. When the `use_composition`
37+
parameter is set to `True`, the associated ROS node will be loaded within a
38+
ROS container. When this happens, all the nodes within the same ROS container
39+
share the same process and can leverage intraprocess communication.
40+
41+
The parameter `create_own_container` only makes sense when `use_composition` is
42+
set to `True`. This parameter lets you control whether your start a ROS
43+
container for your composable nodes or you defer to an external ROS container.
44+
45+
Our recommendation is to always set the `use_composition` parameter to `True`
46+
and decide if you need to create your own container based on your configuration.
47+
Typically, if you're only dealing with your own launch files you'll probably set
48+
`create_own_container` to `True`. On the other hand, if you're using your launch
49+
files as part of a more complex startup where a ROS container is already
50+
present, you should set `create_own_container` to `False` and, instead, set the
51+
parameter `container_name` to the existing container name.
52+
53+
That way, the communication between Gazebo, the bridge, and other potential
54+
ROS nodes will be intraprocess.
55+
56+
![composition_options](images/composition_options.png)
57+
58+
This figure illustrates the concept of composition. The left diagram captures
59+
the idea of not using composition. All the three example nodes are standalone
60+
nodes, and they can talk via interprocess communication. The center diagram
61+
represents the scenario where we use composition and we start our own container
62+
from our own launch file. All communication is intraprocess here. The right
63+
diagram is still using composition but the launch file doesn't start the
64+
container directly. This setup by itself will not work until you start an
65+
external ROS container (manually or via a separate launch file).
4566

4667
You can learn more about ROS composition in [this tutorial](https://docs.ros.org/en/galactic/Tutorials/Intermediate/Composition.html).
4768

images/composition_options.png

123 KB
Loading

0 commit comments

Comments
 (0)