ROS 1 bridge requires the topic to be published both sides
I'm following the ROS 1 / 2 communication steps from this ROS-I tuto trying to run a simple example : publish some Bool
msg in ROS 1 and echo in ROS 2, and vice versa. As advised in the tuto, I have 3 workspaces: ros_ws
for Noetic, ros2_ws
for Foxy, ros1_bridge_ws
for the bridge (foxy branch, compiled successfully with colcon). I'm running all terminals in localhost with default settings and DDS implementation.
Terminal 1: Bridge in ros1_bridge_ws
workspace
source ros1_bridge_ws/install/setup.bash
ros2 run ros1_bridge dynamic_bridge
Terminal 2: roscore in ros_ws
workspace
source ros_ws/devel/setup.bash
roscore
The bridge in terminal 1 then warns:
[ERROR] [1595868742.350252486]: Tried to advertise on topic [/rosout] with latch=0 but the topic is already advertised with latch=1
created 2to1 bridge for topic '/rosout' with ROS 2 type 'rcl_interfaces/msg/Log' and ROS 1 type 'rosgraph_msgs/Log'
Terminal 3: rostopic pub in ros_ws
workspace
ROS 1 will publish False
booleans every second:
source ros_ws/devel/setup.bash
rostopic pub /test std_msgs/Bool "data: false" -r1
The bridge does not display anything new.
Terminal 4: rostopic echo in ros2_ws
workspace
ros2 topic echo /test
WARNING: topic [/test] does not appear to be published yet
Could not determine the type for the passed topic
Thus ROS 2 does not get any message from ROS 1. I keep the publisher and subscriber open.
Terminal 5: ros2 topic pub in ros2_ws
workspace
ROS 2 will publish True
booleans every second:
source ros2_ws/install/setup.bash
ros2 topic pub /test std_msgs/Bool "data: true"
The bridge does not display anything new.
Terminal 4: rostopic echo in ros2_ws
workspace
Back to the temrinal 4 that was falling to retrieve False
messages from ROS1 and retry the echo:
ros2 topic echo /test
Now the echo receives successfully both True
and False
messages from ROS 1 and ROS 2 but also the bridge has noticed a new conversion to be made:
created 1to2 bridge for topic '/test' with ROS 1 type 'std_msgs/Bool' and ROS 2 type 'std_msgs/msg/Bool'
[INFO] [1595869460.462758826] [ros_bridge]: Passing message from ROS 1 std_msgs/Bool to ROS 2 std_msgs/msg/Bool (showing msg only once per type)
[WARN] [1595869460.463629720] [ros_bridge]: Message from ROS 2 rcl_interfaces/msg/Log failed to be passed to ROS 1 rosgraph_msgs/Log because the ROS 1 publisher is invalid (showing msg only once per type)
Conclusion
Why do I need to publish both sides to get some messages? Note: this issue is identical if the initial publisher is from ROS 1 or ROS 2 side.