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

Making a desktop user program to roslaunch and kill nodes

asked 2016-01-29 03:39:45 -0600

Adri gravatar image

Hello everyone.

I have this problem about making a desktop user program. I hope you can help me:

  1. I would like to create a program for users which could launch different .launch files depending on user's choice. I would like to make it the easiest as possible for them (eg: users would double-click an icon in the desktop and the program would give them the opportunity to roslaunch one .launch or another making users to write simple commands).

  2. Also, this program would recognize when it needs to kill automatically several nodes after a roslaunch (eg: I roslaunch a .launch which shows a turtle moving from initial position to its destiny. When this turtle reaches its destiny, some nodes must be killed automatically, like node which manages to move the turtle).

Problem: I don't know how to do this automatically. I was able to do it manually, but it needs user's interaction. I don't want this to happen.

And the main question is: How would you do this program?

I tried doing that with this structure:

1. .desktop file which executes by double-click the compiled C program I created.

2. C program which make user interaction and call shell scripts (system(call_shell_script);) in order to do roslaunch depending on the command that user writes.

3. One shell script which I use to roslaunch the .launch files.

4. One shell script which manages to kill several nodes.

The best options I want to have are the next (First is the best, last is the worst):

1. Making all of that in just one C or C++ program (no shell scripts, only a .desktop and a GUI).

2. Making all of that using rqt_launch or some tool like that.

3. The structure I used.

4. Making all of that in just one shell script, no C/C++ programs.

5. Others.

Thank you in advance.

edit retag flag offensive close merge delete


perhaps you could extend this

inflo gravatar image inflo  ( 2016-01-29 06:02:41 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-01-29 09:50:06 -0600

I've done this exact same thing in the past. Here's how I did it:

  1. Created all versions of the application using only ROS. I boiled each possible configuration down to a single launch file w/particular arguments. If you set nodes to be required in the launch file, then killing a single required node is sufficient for shutting down all nodes started by the launch file. At this point I could start my ROS application and use something like rospy.signal_shutdown to destroy a required node based on some condition.

  2. Then I wrote a simple Python GUI that allowed me to select options from dropdowns, checkboxes, etc.

  3. A button in the gui then had a callback that would start a single subprocess that was a call to roslaunch with the appropriate launch file and args (as set by the options in the gui).

  4. Then I created a .desktop file that would automatically start the GUI.

One thing to watch out for is that you need to make sure that your GUI has access to the correct ROS environment variables. For example, you could source a setup.bash file in your .desktop file.

edit flag offensive delete link more


Thanks for the answer, but I don't understand one thing:

How do you call several .launch to the same time? I tried to use system("roslaunch package name.launch & roslaunch package2 name2.launch"), but it doesn't work.

Adri gravatar image Adri  ( 2016-02-03 03:13:45 -0600 )edit

I would create a single launch file that includes both of the target launch files using the include tag.

jarvisschultz gravatar image jarvisschultz  ( 2016-02-03 13:11:32 -0600 )edit

Question Tools

1 follower


Asked: 2016-01-29 03:39:45 -0600

Seen: 1,106 times

Last updated: Jan 29 '16