How do we remap all of the input and ouput topics from a node in a systematic way?
The probIem I am facing is that I am using a package with the following launch file:
<launch>
<node pkg="mypackage" type="task_A" name="task_A_node" output="screen">
</node>
<node pkg="mypackage" type="task_B" name="task_B_node" output="screen">
</node>
</launch>
And when running rqt_graph, one will get the following graph:
/input -> /task_A_node -> {/internal_topic1, /internal_topic2}-> /task_B_node -> {/output1, /output2}
Here the topic names "/input", "/internal_topic1", "/internal_topic2", "/output_1", "/output_2" have been hardcoded in the program by the author of the package. There are actually a lot more topics so it's actually quite complicated to modify the code to parameterize the naming of the input/output topics.
Now that I want to run two instances of this program in paralel as black boxes, each with its own input like this:
<launch>
<!-- group 1 -->
<group>
<node pkg="mypackage" type="task_A" name="task_A_node1" output="screen">
</node>
<node pkg="mypackage" type="task_B" name="task_B_node1" output="screen">
</node>
</group>
<!-- group 2 -->
<group>
<node pkg="mypackage" type="task_A" name="task_A_node2" output="screen">
</node>
<node pkg="mypackage" type="task_B" name="task_B_node2" output="screen">
</node>
</group>
</launch>
Now the issue is taht if I don't remap the topics, the input and output of group 1 and group 2 will be mixed. So the way I was thinking to work around this is to remap all topics related to the each instance to the same name with a suffix, for example:
<launch>
<!-- group 1 -->
<group>
<node pkg="mypackage" type="task_A" name="task_A_node1" output="screen">
<remap from="/input" to="/input_group1">
<remap from="/internal_topic1" to="/internal_topic1_group1">
<remap from="/internal_topic2" to="/internal_topic2_group1">
</node>
<node pkg="mypackage" type="task_B" name="task_B_node1" output="screen">
<remap from="/internal_topic1" to="/internal_topic1_group1">
<remap from="/internal_topic2" to="/internal_topic2_group1">
<remap from="/output1" to="/output1_group1">
<remap from="/output2" to="/output2_group1">
</node>
</group>
<!-- group 2 -->
<group>
<node pkg="mypackage" type="task_A" name="task_A_node2" output="screen">
<remap from="/input" to="/input_group2">
<remap from="/internal_topic1" to="/internal_topic1_group2">
<remap from="/internal_topic2" to="/internal_topic2_group2">
</node>
<node pkg="mypackage" type="task_B" name="task_B_node2" output="screen">
<remap from="/internal_topic1" to="/internal_topic1_group2">
<remap from="/internal_topic2" to="/internal_topic2_group2">
<remap from="/output1" to="/output1_group2">
<remap from="/output2" to="/output2_group2">
</node>
</group>
</launch>
So I want to ask if there is anyway to quickly remap all topics that come in and out of a node to something with the same name but with a suffix MORE EFFECIENTLY, other than having to do that one by one like I did above?
Thanks!
Edit: clarifying the issue with examples.