Topic remapping in launch.xml is not working for topic_tools/mux node
The documentation for topic_tools/mux says:
IMPORTANT: To avoid conflicting with other instances of mux, you should always remap the mux's node name to something descriptive, using the mux:=foo syntax on the command line.
And indeed if I run
$ rosrun topic_tools mux output input1 input2 mux:=foobar &
$ rosservice list
I can see through the service list that the node's services has been remapped to /foobar/add
and so on.
However if I put the equivalent entry in my launch.xml
:
<node name="mux" pkg="topic_tools" type="mux" args="output input1 input2">
<remap from="mux" to="foobar" />
</node>
then the remapping does not work; the service uses the default names of /mux/add
, etc.
The process list entries seem similar:
# roslaunch, not working
/opt/ros/noetic/lib/topic_tools/mux output input1 input2 mux:=foobar __name:=mux __log:=/root/.ros/log/1edcbb1e-ea9d-11ec-a797-0242ac110002/mux-7.log
# rosrun, working
/opt/ros/noetic/lib/topic_tools/mux output input1 input2 mux:=foobar
The behavior is baffling. When __name:=mux
is provided, the topic remapping does not work. But if I omit __name:=mux
or provide ANY name other than mux
the remapping succeeds.
I could possibly understand if the remapping mux:=foobar
caused __name:=mux
to become __name:=foobar
but it doesn't make sense for __name:=mux
to cause mux:=foobar
to be ignored.
Asked by rgov on 2022-06-12 17:25:44 UTC
Answers
if I run
$ rosrun topic_tools mux output input1 input2 mux:=foobar & $ rosservice list
I can see through the service list that the node's services has been remapped to
/foobar/add
and so on.However if I put the equivalent entry in my
launch.xml
:<node name="mux" pkg="topic_tools" type="mux" args="output input1 input2"> <remap from="mux" to="foobar" /> </node>
Shouldn't you be changing the name
attribute of your node
instead?
That's what the documentation of topic_tools
suggests: using a different node name.
The behavior is baffling.
I don't believe it is. This command line:
/opt/ros/noetic/lib/topic_tools/mux output input1 input2 mux:=foobar __name:=mux __log:=/root/.ros/log/1edcbb1e-ea9d-11ec-a797-0242ac110002/mux-7.log
essentially just starts mux
, asks it to remap a resource called mux
to be remapped to foobar
, and then sets the node name to mux
.
It's likely the __name
argument takes precedence, and that rosrun
without __name
will afterwards apply the remap, changing all private services of mux
to use the name(space) foobar
.
But then again, changing names of nodes in .launch
files should be done by setting the name
attribute of node
elements. Not using remap
.
Asked by gvdhoorn on 2022-06-13 02:48:56 UTC
Comments
The documentation for mux says to use mux:=asdf
. I just created a launch file with <node name="asdf" pkg="topic_tools" type="mux" args="/out /a /b" />
without a parameter remap. The launched process is /opt/ros/noetic/lib/topic_tools/mux /out /a /b __name:=asdf
. And the services are all under /mux
and not /asdf
.
Asked by rgov on 2022-06-13 17:53:09 UTC
Comments