1. The role of remap
Remap allows the ROS node to change the topic name published by the subscription to another name. For example<remap from="/old_topic" to="/new_topic"/>
“
or<remap from="topic" to="/device1/topic"/>
2. Question: Why is the topic not implemented as expected after using remap?
After checking through rqt, I found that the new topic expected to be displayed between the two nodes did not appear, and the old topic before remap also did not appear?
3. You can try to find out the reasons from the following negative aspects:
1. You must ensure that remap is performed on both the publishing node and the receiving node of the Topic.
For example:
The original /oldtopic is used to connect two nodes in two launch files, so both launch files must be remap defined. For specific reference:
The launch file where Node1 is located<launch> <node name="node1" > <remap from="/oldtopic" to="/newtopic"/> </node> </launch>
The launch file where Node2 is located<launch> <node name="node2" > <remap from="/oldtopic" to="/newtopic"/> </node> </launch>
2. Check whether there are other ways to modify the topic, but no corresponding modifications have been made.
In other words, check your code to see if the Topic name is written hard in some configuration files or code.
Although remap is performed in the launch file, in addition to the remap tag, there are many ways to achieve topic renaming, such as through namespace (<group ns="device1">
) or write down the topic name in the configuration file or code, but if no corresponding modifications are made to the hard-coded place, it will naturally not work.
Essentially, you must ensure that the path of the Topic is open after each node is started, so that it can be displayed on the rqt visual interface.