Skip to content

Composition and Bridge Updates #528

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

Merged
merged 5 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
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
15 changes: 6 additions & 9 deletions harmonic/ros2_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,18 @@ for a valid configuration file.

The package `ros_gz_bridge` contains a launch file named
`ros_gz_bridge.launch.py`. You can use it to start a ROS 2 and Gazebo bridge.
Here's an example:

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

Alternatively, if an existing container is already running, you can pass its name
when launching the bridge using the `container_name` parameter.

And now, the container will load your bridge with:
Launching with composition:
```bash
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>
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
```
Alternatively, if an existing container is already running, you can pass its name
when launching the bridge using the `container_name` parameter. More info about composition can be viewed [here](ros2_overview#composition)

Check [this block](https://github.com/gazebosim/ros_gz/blob/jazzy/ros_gz_bridge/launch/ros_gz_bridge.launch.py#L27-L34)
from the source code to know all the different parameters accepted by this
Expand Down
23 changes: 16 additions & 7 deletions harmonic/ros2_launch_gazebo.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ def generate_launch_description():
'on_exit_shutdown': 'True'
}.items(),
),
Node(
package='ros_gz_bridge',
executable='parameter_bridge',
arguments=[],
remappings=[],
output='screen'
),
])
```

Expand Down Expand Up @@ -129,3 +122,19 @@ def generate_launch_description():

return ld
```


## Launching with ros_gz_bridge

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)
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)

Example command for directly using these launch files from the terminal:
```bash
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
```

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)

More info about `ros_gz_bridge` can be viewed [here](ros2_integration).
More info about composition can be viewed [here](ros2_overview#composition).
2 changes: 1 addition & 1 deletion harmonic/ros2_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ diagram is still using composition but the launch file doesn't start the
container directly. This setup by itself will not work until you start an
external ROS container (manually or via a separate launch file).

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

## What's next?

Expand Down
19 changes: 16 additions & 3 deletions harmonic/ros2_spawn_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ we have provided the following mechanisms:
*Currently only available in Rolling.*

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

```bash
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
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
```

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

Expand Down Expand Up @@ -60,3 +60,16 @@ within this tag. Here's an example:
In this case the `<gz_spawn_model>` parameters are read from the command line.
That's an option but not strictly necessary as you could decide to hardcode some
of the values or not even use all of the parameters.


## Spawning a model alongside launching ros_gz_bridge

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)
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)

Example command for directly using these launch files from the terminal:
```bash
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>
```

More info about `ros_gz_bridge` can be viewed [here](ros2_integration).
Loading