@@ -85,7 +85,7 @@ Now we start the ROS listener.
85
85
86
86
```
87
87
# Shell B:
88
- . /opt/ros/galactic /setup.bash
88
+ . /opt/ros/iron /setup.bash
89
89
ros2 topic echo /chatter
90
90
```
91
91
@@ -117,7 +117,7 @@ Now we start the ROS talker.
117
117
118
118
```
119
119
# Shell C:
120
- . /opt/ros/galactic /setup.bash
120
+ . /opt/ros/iron /setup.bash
121
121
ros2 topic pub /chatter std_msgs/msg/String "data: 'Hi'" --once
122
122
```
123
123
@@ -155,7 +155,7 @@ Now we start the ROS GUI:
155
155
156
156
```
157
157
# Shell C:
158
- . /opt/ros/galactic /setup.bash
158
+ . /opt/ros/iron /setup.bash
159
159
ros2 run rqt_image_view rqt_image_view /rgbd_camera/image
160
160
```
161
161
@@ -273,9 +273,43 @@ To run the bridge node with the above configuration:
273
273
ros2 run ros_gz_bridge parameter_bridge --ros-args -p config_file:=$WORKSPACE /ros_gz/ros_gz_bridge/test/config/full.yaml
274
274
```
275
275
276
+ ## Example 6: Using ROS namespace with the Bridge
277
+
278
+ When spawning multiple robots inside the same ROS environment, it is convenient to use namespaces to avoid overlapping topic names.
279
+ There are three main types of namespaces: relative, global (` / ` ) and private (` ~/ ` ). For more information, refer to ROS documentation.
280
+ Namespaces are applied to Gazebo topic both when specified as ` topic_name ` as well as ` gz_topic_name ` .
281
+
282
+ By default, the Bridge will not apply ROS namespace on the Gazebo topics. To enable this feature, use parameter ` expand_gz_topic_names ` .
283
+ Let's test our topic with namespace:
284
+
285
+ ``` bash
286
+ # Shell A:
287
+ . ~ /bridge_ws/install/setup.bash
288
+ ros2 run ros_gz_bridge parameter_bridge chatter@std_msgs/msg/
[email protected] \
289
+ --ros-args -p expand_gz_topic_names:=true -r __ns:=/demo
290
+ ```
291
+
292
+ Now we start the Gazebo Transport listener.
293
+
294
+ ``` bash
295
+ # Shell B:
296
+ ign topic -e -t /demo/chatter
297
+ ```
298
+
299
+ Now we start the ROS talker.
300
+
301
+ ``` bash
302
+ # Shell C:
303
+ . /opt/ros/iron/setup.bash
304
+ ros2 topic pub /demo/chatter std_msgs/msg/String " data: 'Hi from inside of a namespace'" --once
305
+ ```
306
+
307
+ By changing ` chatter ` to ` /chatter ` or ` ~/chatter ` you can obtain different results.
308
+
276
309
## API
277
310
278
311
ROS 2 Parameters:
279
312
280
313
* ` subscription_heartbeat ` - Period at which the node checks for new subscribers for lazy bridges.
281
314
* ` config_file ` - YAML file to be loaded as the bridge configuration
315
+ * ` expand_gz_topic_names ` - Enable or disable ROS namespace applied on GZ topics.
0 commit comments