I have a written several launch files that work. But the format of topic_tools mux with its list of unnamed arguments baffles me. I can make things work with
rosrun topic_tools mux sel_cmdvel joystick/cmd_vel cmd_vel mux:=mux_cmdvel
How can I put this in a launch file? like the following which doesn't work.
<launch>
<!-- mux_cmdvel installation -->
<node pkg="topic_tools" type="mux" name="mux_cmdvel" args="sel_cmdvel joystick/cmd_vel cmd_vel">
</node>
</launch>
In response to Dornhege's request below, I add the following clarification which may or may not help.
I have a launch file which launchs 2 nodes which compute a joystick cmd_vel called “LeafJS/cmd_vel” and another node, leaf_base, which is a base controller and expects an input topic called sel_cmd_vel. I am using mux to subscribe to the LeafJS/cmd_vel topic and output the sel_cmd_vel topic. Of course the robot’s wheels do not respond to joystick commands at this point since mux isn’t running.
After running rosrun topic_tools mux sel_cmd_vel LeafJS/cmd_vel cmd_vel mux:=mux_cmdvel
, the robot runs with mux selecting the default input LeafJS/cmd_vel
and outputing sel_cmd_vel
to the base controller which drives the wheels. So, the mux is apparently working.
Now, the plot thickens…I run rosnode info mux_cmdvel
as you requested and get
alex@rocky:~$ rosnode info mux_cmdvel
--------------------------------------------------------------------------------
Node [/mux_cmdvel]
Publications: None
Subscriptions: None
Services: None
cannot contact [/mux_cmdvel]: unknown node
So, I look at rqt_graph which indicates that the mux node is actually called sel_cmd_vel_mux_1380399404626786209
If I rosnode info this node, I get:
alex@rocky:~$ rosnode info sel_cmd_vel_mux_1380399404626786209
--------------------------------------------------------------------------------
Node [/sel_cmd_vel_mux_1380399404626786209]
Publications:
* /mux_cmdvel/selected [std_msgs/String]
* /rosout [rosgraph_msgs/Log]
* /sel_cmd_vel [geometry_msgs/Twist]
Subscriptions:
* /LeafJS/cmd_vel [geometry_msgs/Twist]
* /cmd_vel [unknown type]
Services:
* /mux_cmdvel/delete
* /mux_cmdvel/list
* /mux_cmdvel/add
* /sel_cmd_vel_select
* /sel_cmd_vel_mux_1380399404626786209/set_logger_level
* /sel_cmd_vel_mux_1380399404626786209/get_loggers
* /mux_cmdvel/select
contacting node http://rocky:49171/ ...
Pid: 4008
Connections:
* topic: /rosout
* to: /rosout
* direction: outbound
* transport: TCPROS
* topic: /sel_cmd_vel
* to: /leaf_base
* direction: outbound
* transport: TCPROS
* topic: /sel_cmd_vel
* to: /rostopic_4120_1380399530443
* direction: outbound
* transport: TCPROS
* topic: /LeafJS/cmd_vel
* to: /leaf_teleop_joystick (http://rocky:44908/)
* direction: inbound
* transport: TCPROS
My rosrun mux… command seems just like the example in the wiki, so I don’t see why it has the long name rather than the simple assignment to mux_cmdvel. But, it is working.
If I do run the mux launch file above, I do get a mux_cmdvel node with the following info:
alex@rocky:~$ rosnode info mux_cmdvel
--------------------------------------------------------------------------------
Node [/mux_cmdvel]
Publications:
* /mux_cmdvel/selected [std_msgs/String]
* /rosout [rosgraph_msgs/Log]
Subscriptions:
* /cmd_vel [unknown type]
Services:
* /mux_cmdvel/set_logger_level
* /mux_cmdvel/delete
* /mux_cmdvel/list
* /mux_cmdvel/add
* /LeafJS/cmd_vel_select
* /mux_cmdvel/select
* /mux_cmdvel/get_loggers
contacting node http://rocky:44309/ ...
Pid: 4684
Connections:
* topic: /rosout
* to: /rosout
* direction: outbound
* transport: TCPROS
which seems to indicate it is launching some kind of default mux with the specified name, but not setting it up per the arguments. So my question remains, how do I specify the arguments so that the mux node is using LeafJS/cmd_vel and cmd_vel as input sources and outputting sel_cmd_vel
Originally posted by Alex Brown on ROS Answers with karma: 176 on 2013-09-27
Post score: 2
Original comments
Comment by dornhege on 2013-09-28:
"doesn't work." - what does that mean?
Comment by Alex Brown on 2013-09-28:
It launches the mux node, but doesn't use any of the args. It does not create a selected output of sel_cmdvel and doesn't subscribe to the two inputs; joystick/cmd_vel and cmd_vel. I suspect the args have to be specified differently. rqt_graph just shows the mux node alone with no connections
Comment by dornhege on 2013-09-28:
What do you get for rosnode info mux_cmdvel
?
Comment by dornhege on 2013-09-30:
Maybe one thing: The mux:=mux_cmdvel should go as a remapping in the launch file.
Comment by dornhege on 2013-09-30:
This doesn't answer the question, but might be a better solution to what you want to do: Check out the cmd_vel_mux: http://wiki.ros.org/cmd_vel_mux .