ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

How to automaticly call different nodes in the same launch file?

asked 2013-07-21 22:47:37 -0600

Astronaut gravatar image

Hello

I would like to have like some how automation in my launch file. I would like to call a node inside launch file while pressing for example button 1. For example pressing button 1(or entering 1) will run the node1 with the output parameters a,b,c. Pressing the button 2 (entering 2) will run the node2 in the same launch file. Any help how to implement this??

Thanks

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-07-22 03:48:15 -0600

thebyohazard gravatar image

updated 2013-07-23 04:03:31 -0600

Launch files have limited built in run time decisions. There are, however, if and unless attributes for all tags. Combined with the arg tag, you could pass in an argument at launch time to conditionally run either node1 or node2 from the same launch file. Maybe you could rig up some code or a script to pass one argument if button1 is pressed and another argument if button2 is pressed.

EDIT

Q: "So in my case an argument is a node, correct?" -@Astronaut

Not the node itself, but an arg on which node to launch. Something like:

<launch>
    <arg name="launch_node_1" default="true" />
    <node if="$(arg launch_node_1)" name="node1" .../>
    <node unless="$(arg launch_node_1)" name="node2" .../>
</launch>

Then a call of roslaunch my_file.launch launch_node_1:=true would launch node1 and a call of roslaunch my_file.launch launch_node_1:=false would launch node2

I've not yet used rqt_launch, but Dan is doubtless more experienced than I.

EDIT 2:

Q: So in a script I have to call first the launch file than the arguments in that launch file, true??And possible to launch more than two nodes? Like button1 will run node1, button2 will run node2, button3 runs node3 etc..

Yes, you will launch the launch file to run any combination of any number of nodes you want, based on whatever arguments you pass in. A launch file is a one time thing, though. roslaunch will keep nodes alive if you tell it to, but it isn't constantly monitoring the status of the arguments. To run different nodes at different times, you shouldn't use a single launch file. It wasn't built for that.

edit flag offensive delete link more

Comments

Thanks. So in my case an argument is a node, correct? So can rig up some code than can pass argument 1(node 1) if button 1 (for example keyboard button 1) is pressed. Correct?

Astronaut gravatar image Astronaut  ( 2013-07-22 04:24:38 -0600 )edit

And using Qt would not be much easier and more elegant solution?

Astronaut gravatar image Astronaut  ( 2013-07-22 04:29:31 -0600 )edit

So in a script I have to call first the launch file than the arguments in that launch file, true??And possible to launch more than two nodes? Like button1 will run node1, button2 will run node2, button3 runs node3 etc.. ??

Astronaut gravatar image Astronaut  ( 2013-07-22 19:15:17 -0600 )edit

And when I use the arguments in launch file means I have single launch file and can run different nodes based on the arguments value?? Here is no input from the keyboard taken into account, true?

Astronaut gravatar image Astronaut  ( 2013-07-23 04:12:34 -0600 )edit
1

answered 2013-07-22 05:08:30 -0600

Have you looked at rqt_launch? It may be able to do at least some of what you want.

edit flag offensive delete link more

Comments

No, didnt look at rqt_launch... But when I checked its only for Groovy. Im using ROS Fuerte. is that ok? Any documentation or tutorial regarding this problem implementation with rqt_launch on Fuerte?

Astronaut gravatar image Astronaut  ( 2013-07-22 15:29:05 -0600 )edit

You can download src of `rqt_launch`, or the entire metapackage it resides in. It should work on `fuerte`. We're not planning to merge back newer stuff into fuerte, which is planned to End-Of-Life soon.

130s gravatar image 130s  ( 2013-07-22 17:24:13 -0600 )edit

And rqt_launch is still missing many features some of which seem available on its GUI...working on those is on my todolist but not on the top..

130s gravatar image 130s  ( 2013-07-22 17:26:48 -0600 )edit

So also no C++ src. any documentation or help how to use the src?

Astronaut gravatar image Astronaut  ( 2013-07-22 17:37:33 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2013-07-21 22:47:37 -0600

Seen: 819 times

Last updated: Jul 23 '13