You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: harmonic/ros2_integration.md
+65-10
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
-
# ROS 2 Integration
1
+
# Use ROS 2 to interact with Gazebo
2
2
3
-
In this tutorial we will learn how to Integrate ROS 2 with Gazebo. We will establish
4
-
communication between them. This can help in many aspects; we can receive data (like joint states, TFs) or commands
3
+
In this tutorial we will learn how to use ROS 2 to communicate with Gazebo.
4
+
This can help in many aspects; we can receive data (like joint states, TFs) or commands
5
5
from ROS and apply it to Gazebo and vice versa. This can also help to enable RViz to visualize a robot model
6
6
simulatenously simulated by a Gazebo world.
7
7
@@ -11,13 +11,7 @@ simulatenously simulated by a Gazebo world.
11
11
12
12
Example uses of the bridge can be found in [`ros_gz_sim_demos`](https://github.com/gazebosim/ros_gz/tree/ros2/ros_gz_sim_demos), including demo launch files with bridging of all major actuation and sensor types.
13
13
14
-
## Requirements
15
-
16
-
Please follow the [Install Gazebo and ROS document](/docs/latest/ros_installation)
17
-
before starting this tutorial. A working installation of ROS 2 and Gazebo is
18
-
required to go further.
19
-
20
-
## Bidirectional communication
14
+
## Launching the bridge manually
21
15
22
16
We can initialize a bidirectional bridge so we can have ROS as the publisher and Gazebo as the subscriber or vice versa. The syntax is `/TOPIC@ROS_MSG@GZ_MSG`, such that `TOPIC` is the Gazebo internal topic, `ROS_MSG` is the ROS message type for this topic, and `GZ_MSG` is the Gazebo message type.
23
17
@@ -48,6 +42,67 @@ It is also possible to use ROS Launch with the `ros_gz_bridge` and represent the
48
42
direction: GZ_TO_ROS # BIDIRECTIONAL or ROS_TO_GZ
49
43
```
50
44
45
+
The configuration file is a YAML file that contains the mapping between the ROS
46
+
and Gazebo topics to be bridged. For each pair of topics to be bridged, the
47
+
following parameters are accepted:
48
+
49
+
*`ros_topic_name`: The topic name on the ROS side.
50
+
*`gz_topic_name`: The corresponding topic name on the Gazebo side.
51
+
*`ros_type_name`: The type of this ROS topic.
52
+
*`gz_type_name`: The type of this Gazebo topic.
53
+
*`subscriber_queue`: The size of the ROS subscriber queue.
54
+
*`publisher_queue`: The size of the ROS publisher queue.
55
+
*`lazy`: Whether there's a lazy subscriber or not. If there's no real
56
+
subscribers the bridge won't create the internal subscribers either. This should
57
+
speedup performance.
58
+
*`direction`: It's possible to specify `GZ_TO_ROS`, `ROS_TO_GZ` and
59
+
`BIDIRECTIONAL`.
60
+
61
+
See [this example](https://github.com/gazebosim/ros_gz/blob/ros2/ros_gz_bridge/test/config/full.yaml)
62
+
for a valid configuration file.
63
+
64
+
## Launching the bridge using the launch files included in `ros_gz_bridge` package.
65
+
66
+
The package `ros_gz_bridge` contains a launch file named
67
+
`ros_gz_bridge.launch.py`. You can use it to start a ROS 2 and Gazebo bridge.
to orchestrate the launch of all your components and many tooling around it.
10
+
Gazebo can be launched in this way.
11
+
12
+
* Use ROS to interact with Gazebo topics via the [`ros_gz` bridge](https://github.com/gazebosim/ros_gz):
13
+
Once Gazebo is up and running, it's very common to communicate with the
14
+
simulation. A common way to perform this communication is via topics. Gazebo has
15
+
its own middleware, Gazebo Transport, that exposes a set of topics and services quite similar to ROS. The `ros_gz` bridge allows you to create a bridge between
16
+
Gazebo and your ROS system, that translates between Gazebo Transport and ROS 2
17
+
as needed.
18
+
19
+
* Use ROS to spawn a Gazebo model: Gazebo worlds can include models that are
20
+
loaded at startup. However, sometimes you need to spawn models at runtime. This
21
+
task can be performed using ROS 2.
22
+
23
+
## Requirements
24
+
25
+
Please follow the [Install Gazebo and ROS document](/docs/latest/ros_installation)
26
+
before starting this tutorial. A working installation of ROS 2 and Gazebo is
27
+
required to go further.
28
+
29
+
## Composition
30
+
31
+
If you inspect the parameters of the launch files mentioned in the next
32
+
tutorials, you'll notice that we have included in most cases a parameter named
33
+
`use_composition`. When that parameter is set to `True`, the associated ROS
34
+
node will be included within a ROS container. When this happens all the nodes
35
+
live within the same process and can leverage intraprocess communication.
36
+
37
+
Our recommendation is to always set the `use_composition` parameter to `True`.
38
+
That way, the communication between Gazebo and the bridge will be intraprocess.
39
+
If your ROS nodes are also written as composable nodes, make sure that they are
40
+
launched with the `container_node_name` parameter matching the container name
41
+
including Gazebo and the bridge.
42
+
43
+
You can learn more about ROS composition in [this tutorial](https://docs.ros.org/en/galactic/Tutorials/Intermediate/Composition.html).
0 commit comments