Skip to content

Commit 4f93d11

Browse files
authored
Composition and Bridge Updates (#528)
* Composition and Bridge Updates Signed-off-by: Aarav Gupta <[email protected]> * Update composition_options.png Signed-off-by: Aarav Gupta <[email protected]> * Add documentation for spawning a model alongside launch ros_gz_bridge Signed-off-by: Aarav Gupta <[email protected]> * Undo changes made to comopsition_options.png Has been done in #531 Signed-off-by: Aarav Gupta <[email protected]> --------- Signed-off-by: Aarav Gupta <[email protected]> Signed-off-by: Aarav Gupta <[email protected]>
1 parent 0e243eb commit 4f93d11

File tree

4 files changed

+39
-20
lines changed

4 files changed

+39
-20
lines changed

harmonic/ros2_integration.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,18 @@ for a valid configuration file.
6565

6666
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.
68-
Here's an example:
6968

70-
Note: If you run the bridge as a standalone node with composition enabled,
71-
you'll need to create a container first.
69+
Here's an example:
7270
```bash
73-
ros2 run rclcpp_components component_container --ros-args -r __node:=ros_gz_container
71+
ros2 launch ros_gz_bridge ros_gz_bridge.launch.py bridge_name:=ros_gz_bridge config_file:=<path_to_your_YAML_file>
7472
```
7573

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-
79-
And now, the container will load your bridge with:
74+
Launching with composition:
8075
```bash
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>
76+
ros2 launch ros_gz_bridge ros_gz_bridge.launch.py bridge_name:=ros_gz_bridge config_file:=<path_to_your_YAML_file> use_composition:=True create_own_container:=True
8277
```
78+
Alternatively, if an existing container is already running, you can pass its name
79+
when launching the bridge using the `container_name` parameter. More info about composition can be viewed [here](ros2_overview#composition)
8380

8481
Check [this block](https://github.com/gazebosim/ros_gz/blob/jazzy/ros_gz_bridge/launch/ros_gz_bridge.launch.py#L27-L34)
8582
from the source code to know all the different parameters accepted by this

harmonic/ros2_launch_gazebo.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,6 @@ def generate_launch_description():
9393
'on_exit_shutdown': 'True'
9494
}.items(),
9595
),
96-
Node(
97-
package='ros_gz_bridge',
98-
executable='parameter_bridge',
99-
arguments=[],
100-
remappings=[],
101-
output='screen'
102-
),
10396
])
10497
```
10598

@@ -129,3 +122,19 @@ def generate_launch_description():
129122

130123
return ld
131124
```
125+
126+
127+
## Launching with ros_gz_bridge
128+
129+
An example launch file for XML can be viewed [here](https://github.com/gazebosim/ros_gz/blob/jazzy/ros_gz_sim/launch/ros_gz_sim.launch)
130+
An example launch file for Python can be viewed [here](https://github.com/gazebosim/ros_gz/blob/jazzy/ros_gz_sim/launch/ros_gz_sim.launch.py)
131+
132+
Example command for directly using these launch files from the terminal:
133+
```bash
134+
ros2 launch ros_gz_sim ros_gz_sim.launch.py world_sdf_file:=empty.sdf bridge_name:=ros_gz_bridge config_file:=<path_to_your_YAML_file> use_composition:=True create_own_container:=True
135+
```
136+
137+
In the above launch files you may notice that the `create_own_container` argument for `ros_gz_bridge` is hardcoded to `False`. This has been done to prevent two duplicate containers from getting created (one for `gz_server` and another one for `ros_gz_bridge`), and instead make `ros_gz_bridge` use the container created by `gz_server`. More info about this can be viewed [here](https://github.com/gazebosim/ros_gz/pull/620#issue-2595570189)
138+
139+
More info about `ros_gz_bridge` can be viewed [here](ros2_integration).
140+
More info about composition can be viewed [here](ros2_overview#composition).

harmonic/ros2_overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ diagram is still using composition but the launch file doesn't start the
6464
container directly. This setup by itself will not work until you start an
6565
external ROS container (manually or via a separate launch file).
6666

67-
You can learn more about ROS composition in [this tutorial](https://docs.ros.org/en/galactic/Tutorials/Intermediate/Composition.html).
67+
You can learn more about ROS composition in [this tutorial](https://docs.ros.org/en/jazzy/Tutorials/Intermediate/Composition.html).
6868

6969
## What's next?
7070

harmonic/ros2_spawn_model.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ we have provided the following mechanisms:
88
*Currently only available in Rolling.*
99

1010
The package `ros_gz_sim` contains a launch file named
11-
`ros_gz_spawn_model.launch.py`. You can use it to spawn a new model into an
11+
`gz_spawn_model.launch.py`. You can use it to spawn a new model into an
1212
existing simulation. Here's an example:
1313

1414
```bash
15-
ros2 launch ros_gz_sim ros_gz_spawn_model.launch.py world:=empty file:=$(ros2 pkg prefix --share ros_gz_sim_demos)/models/vehicle/model.sdf entity_name:=my_vehicle x:=5.0 y:=5.0 z:=0.5
15+
ros2 launch ros_gz_sim gz_spawn_model.launch.py world:=empty file:=$(ros2 pkg prefix --share ros_gz_sim_demos)/models/vehicle/model.sdf entity_name:=my_vehicle x:=5.0 y:=5.0 z:=0.5
1616
```
1717

18-
Check [this block](https://github.com/gazebosim/ros_gz/blob/jazzy/ros_gz_sim/launch/ros_gz_spawn_model.launch.py#L26-L45)
18+
Check [this block](https://github.com/gazebosim/ros_gz/blob/jazzy/ros_gz_sim/launch/gz_spawn_model.launch.py#L26-L45)
1919
from the source code to know all the different parameters accepted by this
2020
launch file.
2121

@@ -60,3 +60,16 @@ within this tag. Here's an example:
6060
In this case the `<gz_spawn_model>` parameters are read from the command line.
6161
That's an option but not strictly necessary as you could decide to hardcode some
6262
of the values or not even use all of the parameters.
63+
64+
65+
## Spawning a model alongside launching ros_gz_bridge
66+
67+
An example launch file for XML can be viewed [here](https://github.com/gazebosim/ros_gz/blob/jazzy/ros_gz_sim/launch/ros_gz_spawn_model.launch)
68+
An example launch file for Python can be viewed [here](https://github.com/gazebosim/ros_gz/blob/jazzy/ros_gz_sim/launch/ros_gz_spawn_model.launch.py)
69+
70+
Example command for directly using these launch files from the terminal:
71+
```bash
72+
ros2 launch ros_gz_sim ros_gz_spawn_model.launch.py world:=empty file:=$(ros2 pkg prefix --share ros_gz_sim_demos)/models/vehicle/model.sdf entity_name:=my_vehicle x:=5.0 y:=5.0 z:=0.5 bridge_name:=ros_gz_bridge config_file:=<path_to_your_YAML_file>
73+
```
74+
75+
More info about `ros_gz_bridge` can be viewed [here](ros2_integration).

0 commit comments

Comments
 (0)