Robotics StackExchange | Archived questions

How to relay topics on ROS2?

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?

Asked by a.g on 2020-03-30 19:20:21 UTC

Comments

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?

Asked by stevemacenski on 2020-03-31 00:43:31 UTC

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.

Asked by a.g on 2020-03-31 10:36:29 UTC

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

Asked by aserian on 2020-06-30 20:40:17 UTC

Answers