Ask Your Question
1

how to convert rosrun mux command to a launch file

asked 2013-09-27 10:38:49 -0600

Alex Brown gravatar image

updated 2013-09-29 23:09:23 -0600

felix k gravatar image

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 <a href="http://rocky:49171/">http://rocky:49171/</a> ...
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 (<a href="http://rocky:44908/">http://rocky:44908/</a>)
    * 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 <a href="http://rocky:44309/">http://rocky:44309/</a> ...
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 ... (more)

edit retag flag offensive close merge delete

Comments

1

"doesn't work." - what does that mean?

dornhege gravatar imagedornhege ( 2013-09-28 02:49:18 -0600 )edit

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

Alex Brown gravatar imageAlex Brown ( 2013-09-28 03:05:38 -0600 )edit

What do you get for `rosnode info mux_cmdvel`?

dornhege gravatar imagedornhege ( 2013-09-28 03:09:52 -0600 )edit

Maybe one thing: The mux:=mux_cmdvel should go as a remapping in the launch file.

dornhege gravatar imagedornhege ( 2013-09-30 00:03:25 -0600 )edit

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 .

dornhege gravatar imagedornhege ( 2013-09-30 00:04:14 -0600 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2013-09-30 04:36:15 -0600

Alex Brown gravatar image

I got the launch file working this weekend. Dornhege pointed out the missing item this morning. When I wrote the question, I was assuming the "name="mux_cmdvel" item was redundant on the "mux:=mux_cmdvel". Apparently they don't do the same thing.
So, the real answer to my question is that placing all of the rosrun arguments in an "args=" item is proper formatting for a launch statement(which I wasn't sure of). I was just missing the mux:= part. Thanks

edit flag offensive delete link more

Comments

Hi, I am facing the same issue.. can you please explain how you solved it?

Sakshi19K gravatar imageSakshi19K ( 2018-11-29 01:44:48 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-09-27 10:38:49 -0600

Seen: 1,580 times

Last updated: Sep 30 '13