1. Remapping Arguments

  2. Names

ROS Topic Remapping for Nodes

Remapping allows you to "trick" a ROS node so that when it thinks it is subscribing to or publishing to /some_topic it is actually subscribing to or publishing to /some_other_topic, for instance.

Quick Start: Why & How to do this

Sometimes, you may need a message on a specific ROS topic which normally only goes to one set of nodes to also be received by another node. If able, simply tell the new node to subscribe to this other topic. However, you may also do some remapping so that the new node ends up subscribing to /needed_topic when it thinks it is subscribing to /different_topic.

This could be accomplished like so:

<remap from="/different_topic" to="/needed_topic"/>

Now, when this node subscribes to topic /different_topic, the remapping makes it actually subscribe to topic /needed_topic. So, anyone publishing to /needed_topic ends up getting their message to this new node as well!

More on the <remap> tag

The <remap> tag allows you to pass in name remapping arguments to the ROS node that you are launching in a more structured manner than setting the args attribute of a <node> directly. The <remap> tag applies to all subsequent declarations in its scope (<launch>, <node> or <group>).

To understand how remapping resolves names, see Remapping Arguments and Names.

Attributes

  • from="original-name"

    • Remapped topic: name of the ROS topic that you are remapping FROM.

    to="new-name"

    • Target name: name of the ROS topic that you are pointing the from topic TO.

Remember: this means that if you remap FROM topic "A" TO topic "B", then whenever a node thinks it is subscribing to topic "A", it is actually subscribing to topic "B", so anyone publishing to topic "B" will end up getting their message to this node!

Another Example

For example, you are given a node that says it subscribes to the "chatter" topic, but you only have a node that publishes to the "hello" topic. They are the same type, and you want to pipe your "hello" topic into the new node which wants "chatter". You can do this with this remap:

<remap from="chatter" to="hello"/>

Again, this example is from the perspective of the receiving node which subscribes to the topic. So, when this node subscribes to topic "chatter" in its source code, it is remapped to actually subscribe to "hello", so that it ends up receiving any messages published by other ROS nodes to "hello".

Important Notes

  1. Remapping applies to the lines following the remap. Nodes that are launched before any remap lines are not affected.

  2. Remapping affects both which topics a node subscribes to or publishes to. However, usually remapping is done on the subscribing node, meaning that it is actually subscribing to the remapped topic. Therefore, any publishing nodes end up getting their messages to that node by publishing to the topic specified in the to field in the remap command! This may seem backwards at first, but once understood from the perspective of the subscribing node (which is the one remapped in this example), it makes perfect sense.

Wiki: roslaunch/XML/remap (last edited 2020-10-08 20:23:48 by Gabriel Staples)