-
Notifications
You must be signed in to change notification settings - Fork 300
docs: add ROS2 + Gazebo Docker bridge setup guide for harmonic, ionic… #682
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
Open
Not-NeoN-sup
wants to merge
5
commits into
gazebosim:master
Choose a base branch
from
Not-NeoN-sup:add-docker-bridge-docs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+930
−0
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9a91fd6
docs: add ROS2 + Gazebo Docker bridge setup guide for harmonic, ionic…
Not-NeoN-sup cff2d60
changes addressed
Not-NeoN-sup 9a0f984
accidently deleted some stuff
Not-NeoN-sup 3cb72f6
Merge branch 'master' into add-docker-bridge-docs
Not-NeoN-sup 6fc1d56
Merge upstream/master - keep tutorial files with local changes
Not-NeoN-sup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| # ROS 2 + Gazebo Docker Bridge | ||
|
|
||
| A two-container Docker setup for running Gazebo and ROS 2 as separate services connected over a custom Docker network, with the ros_gz_bridge handling topic communication between them | ||
|
|
||
| --- | ||
|
|
||
| ## Compatibility | ||
|
|
||
| | ROS 2 | Gazebo | | ||
| |---|---| | ||
| | Rolling | Jetty | | ||
| | Kilted | Ionic | | ||
| | Jazzy | Harmonic | | ||
| | Iron | Harmonic | | ||
| | Humble | Fortress | | ||
|
|
||
| --- | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Docker installed and running | ||
| - Both images built: | ||
| - `gazebo` — from your Gazebo Dockerfile | ||
| - `ros2` — from your ROS 2 Dockerfile | ||
| - `ros-gz-bridge` installed | ||
|
|
||
| --- | ||
|
|
||
| ## Setup | ||
|
|
||
| ### 1. Create the Docker Network | ||
|
|
||
| ```bash | ||
| docker network create ros-link | ||
| ``` | ||
|
|
||
| ### 2. Start Containers | ||
|
|
||
| ```bash | ||
| docker run -it -d --name gazebo-container --network ros-link gazebo sleep infinity | ||
| docker run -it -d --name ros2-container --network ros-link ros2 sleep infinity | ||
| ``` | ||
|
|
||
| ### 3. Check Container IPs | ||
|
|
||
|
|
||
| ```bash | ||
| docker network inspect ros-link | ||
| ``` | ||
|
|
||
| Example output: | ||
| ```json | ||
| [ | ||
| { | ||
| "Name": "ros-link", | ||
| "Driver": "bridge", | ||
| "IPAM": { | ||
| "Config": [{ "Subnet": "172.21.0.0/16", "Gateway": "172.21.0.1" }] | ||
| }, | ||
| "Containers": { | ||
| "281b3cbfba6a...": { | ||
| "Name": "ros2-container", | ||
| "IPv4Address": "172.21.0.3/16" //<ros-ip> | ||
| }, | ||
| "c2410d610249...": { | ||
| "Name": "gazebo-container", | ||
| "IPv4Address": "172.21.0.2/16" //<gz-ip> | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### 4. Configure Environment Variables | ||
|
|
||
| **In `gazebo-container`:** | ||
| ```bash | ||
| export GZ_IP=<gz-ip> | ||
| export GZ_PARTITION=gazebo-container | ||
| ``` | ||
|
|
||
| **In `ros2-container`:** | ||
| ```bash | ||
| export GZ_IP=<ros-ip> | ||
| export GZ_PARTITION=gazebo-container | ||
| source /opt/ros/<ros-distro>/setup.bash | ||
| ``` | ||
|
|
||
| :::{important} | ||
| Add these to `~/.bashrc` in each container to be available across sessions. | ||
| ::: | ||
|
|
||
| :::{note} | ||
| When setting `GZ_IP`, use only the IP address without the subnet mask. For example: | ||
|
|
||
| ```bash | ||
| export GZ_IP=172.21.0.3 | ||
| ``` | ||
|
|
||
| Do not include `/16`. | ||
| ::: | ||
|
|
||
| --- | ||
|
|
||
| ### 5. Install the Bridge | ||
|
|
||
| ```bash | ||
| apt-get update && apt-get install -y ros-<ros-distro>-ros-gz-bridge | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Using a Config File (optional) | ||
|
|
||
| if you have a `bridge.yaml` config file, you can use it instead of passing topics as arguments: | ||
|
|
||
| ```bash | ||
| ros2 run ros_gz_bridge parameter_bridge --ros-args -p config_file:=/path/to/bridge.yaml | ||
| ``` | ||
|
|
||
| See the [ros_gz_bridge examples](https://github.com/gazebosim/ros_gz/tree/ros2/ros_gz_bridge/examples) for sample configuration files. | ||
|
|
||
| --- | ||
|
|
||
| ## Running the Bridge | ||
|
|
||
| ### Terminal 1 — Start Gazebo sim | ||
|
|
||
| ```bash | ||
| docker exec -it gazebo-container bash | ||
| gz sim shapes.sdf | ||
| ``` | ||
|
|
||
| ### Terminal 2 — Start the bridge | ||
|
|
||
| ```bash | ||
| docker exec -it ros2-container bash | ||
| source /opt/ros/<ros-distro>/setup.bash | ||
| ``` | ||
|
|
||
| #### Option 1: Single topic (basic) | ||
| ```bash | ||
| ros2 run ros_gz_bridge parameter_bridge \ | ||
| /clock@rosgraph_msgs/msg/Clock@gz.msgs.Clock | ||
| ``` | ||
|
Comment on lines
+138
to
+147
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should clarify that this step is not needed if using the yaml method mentioned above.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
|
|
||
| #### Option 2: Multiple topics | ||
| ```bash | ||
| ros2 run ros_gz_bridge parameter_bridge \ | ||
| /clock@rosgraph_msgs/msg/Clock@gz.msgs.Clock \ | ||
| /world/default/model/vehicle/cmd_vel@geometry_msgs/msg/Twist@gz.msgs.Twist \ | ||
| /world/default/model/vehicle/odometry@nav_msgs/msg/Odometry@gz.msgs.Odometry | ||
| ``` | ||
|
|
||
| #### Option 3: Using config file | ||
| ```bash | ||
| ros2 run ros_gz_bridge parameter_bridge --ros-args -p config_file:=/path/to/bridge.yaml | ||
| ``` | ||
| See the [ros_gz_bridge examples](https://github.com/gazebosim/ros_gz/tree/ros2/ros_gz_bridge/examples) for sample configuration files. | ||
|
|
||
| ### Terminal 3 — Verify | ||
|
|
||
| ```bash | ||
| docker exec -it ros2-container bash | ||
| source /opt/ros/<ros-distro>/setup.bash | ||
| ros2 topic echo /clock | ||
| ``` | ||
| if you see something like this :- | ||
| ```bash | ||
| clock: | ||
| sec: 0 | ||
| nanosec: 0 | ||
| --- | ||
| clock: | ||
| sec: 0 | ||
| nanosec: 0 | ||
| --- | ||
| clock: | ||
| sec: 0 | ||
| nanosec: 0 | ||
| --- | ||
| ``` | ||
| then the connection between the two docker containers is succesfull | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Gazebo Tutorials | ||
|
|
||
| These tutorials cover general concepts to help get you started with Gazebo. | ||
|
|
||
| ## Basics tutorials | ||
|
|
||
| * [Building Your Own Robot](building_robot) | ||
| * [Moving the Robot](moving_robot) | ||
| * [SDF Worlds](sdf_worlds) | ||
| * [Sensors](sensors) | ||
| * [Actors](actors) | ||
|
|
||
| ## GUI tutorials | ||
|
|
||
| * [Understanding the GUI](gui) | ||
| * [Manipulating Models](manipulating_models) | ||
| * [Model Insertion from Fuel](fuel_insert) | ||
| * [Keyboard Shortcuts](hotkeys) | ||
|
|
||
| ## ROS integration | ||
|
|
||
| * [Spawn URDF](spawn_urdf) | ||
| * [ROS 2 Integration](ros2_integration) | ||
| * [ROS 2 Interoperability](ros2_interop) | ||
| * [ROS 2 Integration Template](ros_gz_project_template_guide) | ||
| * [ROS 2 Cross Docker Bridge Setup](ros2_gz_docker_bridge) | ||
|
|
||
| ## Per-library tutorials | ||
|
|
||
| See the *API & Tutorials* sections on the [Libraries page](/libs){.external} page for more specific content correlating to each Gazebo library. | ||
|
|
||
| The entrypoint library is Sim. | ||
| - [Sim](/api/sim/7/tutorials.html){.external} | ||
|
|
||
| Other libraries: | ||
| - [Cmake](/api/cmake/3/tutorials.html){.external} | ||
| - [Common](/api/common/5/tutorials.html){.external} | ||
| - [Fuel_tools](/api/fuel_tools/8/tutorials.html){.external} | ||
| - [Gui](/api/gui/7/tutorials.html){.external} | ||
| - [Launch](/api/launch/6/tutorials.html){.external} | ||
| - [Math](/api/math/7/tutorials.html){.external} | ||
| - [Msgs](/api/msgs/9/tutorials.html){.external} | ||
| - [Physics](/api/physics/6/tutorials.html){.external} | ||
| - [Plugin](/api/plugin/2/tutorials.html){.external} | ||
| - [Rendering](/api/rendering/7/tutorials.html){.external} | ||
| - [Sensors](/api/sensors/7/tutorials.html){.external} | ||
| - [Tools](/api/tools/2/tutorials.html){.external} | ||
| - [Transport](/api/transport/12/tutorials.html){.external} | ||
| - [Utils](/api/utils/2/tutorials.html){.external} | ||
| - [Sdformat](/api/sdformat/13/){.external} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The subnet mask (
/16) would need to be removed before setting GZ_IP. Can you add a statement or example about that?