@@ -9,7 +9,7 @@ This package has been tested in Ubuntu 18.04 with
9
9
A Dockerfile with the prerequisites is provided.
10
10
11
11
12
- # Basic bridge usage
12
+ # Bridge a custom message type
13
13
14
14
This example demonstrates basic communication between publisher and subscriber across ROS 1 and ROS 2.
15
15
@@ -36,6 +36,14 @@ colcon build --packages-select bridge_msgs
36
36
python3 src/bridge_msgs/src/ros2_pub.py
37
37
```
38
38
39
+ The publisher will produce output like this:
40
+ ```
41
+ Published joint_command
42
+ Published joint_command
43
+ Published joint_command
44
+ Published joint_command
45
+ ```
46
+
39
47
Shell 3, check out and compile ` ros1_bridge ` from source to recognize the custom message we just compiled above:
40
48
```
41
49
mkdir -p ros1_bridge_sandbox/bridge_ws/src
49
57
. ~/ros1_bridge_sandbox/ros2_msgs_ws/install/local_setup.bash
50
58
# Compile ros1_bridge and source it
51
59
colcon build --packages-select ros1_bridge --cmake-force-configure
52
- . install/setup .bash
60
+ . install/local_setup .bash
53
61
# This should print: - 'bridge_msgs/JointCommand' (ROS 2) <=> 'bridge_msgs/JointCommand' (ROS 1)
54
62
ros2 run ros1_bridge dynamic_bridge --print-pairs | grep bridge
55
- - 'bridge_msgs/msg/JointCommand' (ROS 2) <=> 'bridge_msgs/JointCommand' (ROS 1)
56
63
```
57
64
58
65
If the ` grep ` does not print anything, verify that the ROS 1 and ROS 2 messages are both recognized in this shell:
@@ -73,25 +80,39 @@ Run the bridge, which will carry messages across ROS 1 and 2:
73
80
ros2 run ros1_bridge dynamic_bridge
74
81
```
75
82
76
- Shell 1, test subscribing to ROS 2 messages in ROS 1:
83
+ Shell 1, test subscribing to ROS 2 messages in ROS 1.
84
+ You should see printouts on the screen:
77
85
```
78
- rosrun bridge_msgs ros1_sub.py
86
+ $ rosrun bridge_msgs ros1_sub.py
87
+ [INFO] [1571738769.812788]: 0.703536987438
88
+ [INFO] [1571738769.866240]: 0.620796272812
89
+ [INFO] [1571738769.919718]: 0.615485199642
90
+ [INFO] [1571738769.972993]: 0.556240315522
79
91
```
80
- You should see printouts on the screen.
81
92
82
93
If the executable is not found, make sure you have sourced the package:
83
94
```
84
95
. devel_isolated/setup.bash
85
96
```
86
97
87
- In the other direction, test subscribing to ROS 1 messages in ROS 2:
98
+ Keeping the bridge running in Shell 3, try the other direction, subscribing to
99
+ ROS 1 messages in ROS 2.
100
+
88
101
Shell 1:
89
102
```
90
- rosrun bridge_msgs ros1_pub.py
103
+ $ rosrun bridge_msgs ros1_pub.py
104
+ published joint_command 0.337332
105
+ published joint_command 0.004804
106
+ published joint_command 0.022121
107
+ published joint_command 0.100489
91
108
```
92
109
Shell 2:
93
110
```
94
- ros2 run bridge_msgs ros2_sub.py
111
+ $ python3 src/bridge_msgs/src/ros2_sub.py
112
+ received joint_command 0.337332
113
+ received joint_command 0.004804
114
+ received joint_command 0.022121
115
+ received joint_command 0.100489
95
116
```
96
117
97
118
0 commit comments