How to relay topics on ROS2?

asked 2020-03-30 19:20:21 -0500

a.g gravatar image

I have setup 2 computers which communicate with each other directly in ROS2.

However, I would like to introduce a relay station (third computer) in the middle of communications. Is there a simple way to forward topics to a different a name? I have heard of the topic_tools pkg in ROS1 but is there something similar in ROS2?

edit retag flag offensive close merge delete


So you're saying a few things here and I want to make sure I get you correct. You you computer A, B, and C, and you'd like communication from A that went to C to now also go through B? And on top of that, you want to relay specific topics from topicA to topicB in that transition?

stevemacenski gravatar image stevemacenski  ( 2020-03-31 00:43:31 -0500 )edit

Yes that is exactly what I am trying to do. For example, the topic cmd_vel is normally exchanged between A and C. Now it will be called /relay/cmd_vel and sent from A to B. Then, it will be renamed to the topic /robot/cmd_vel and sent from B to C.

a.g gravatar image a.g  ( 2020-03-31 10:36:29 -0500 )edit

Pretty much answered your own question there. Create a node (B) that 1) subscribes to /relay/cmd_vel and 2) publishes on /robot/cmd_vel. When it receives a message on /relay/cmd_vel, publish it to /robot/cmd_vel in the callback. Node C listens on /robot/cmd_vel, Node A publishes on /relay/cmd_vel

aserian gravatar image aserian  ( 2020-06-30 20:40:17 -0500 )edit