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

Parameters roslaunch from python script

asked 2017-07-08 14:35:28 -0600

Enriq gravatar image

updated 2017-07-08 14:43:44 -0600

Hello,

I need to run various nodes and launch files from my python script. I know there is an API in python to do it, but the example it's quite simple and I need to give some arguments (for example: where is the file to load the map).

If it isn't a way to do it, I'll do it with subprocess, but I don't know how to pass arguments with roslaunch in command line. Furthermore, doing it with subprocess is way less elegant, but it could help.

edit retag flag offensive close merge delete

Comments

lunar (and presumably melodic and beyond) has the capability to have arguments now according to http://wiki.ros.org/roslaunch/API%20U... .

It would be very convenient if it could be backported.

lucasw gravatar image lucasw  ( 2018-06-19 16:04:39 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-07-08 19:43:51 -0600

Ed Venator gravatar image

I don't have an answer to your first question (supplying args through the roslaunch python API), but if you decide to use subprocess, you can supply args on the command line this:

roslaunch pkg file.launch arg_name:=arg_value arg2_name:=arg2_value

You could pretty easily put that into a subprocess call.

edit flag offensive delete link more

Comments

Thank you, that's what I was looking for. But I can't use communicate (as below) as long as I want the script to be running more things (and use p4.terminate() later)

p4 = subprocess.Popen(list_args , stdout=subprocess.PIPE) output4 = p4.communicate()[0] print output4 #Stuck p4.terminate #Dont work

Enriq gravatar image Enriq  ( 2017-07-09 06:12:56 -0600 )edit
1

I think the problem is that Popen.communicate() blocks until the subprocess exits, and p4 never exits.

Ed Venator gravatar image Ed Venator  ( 2017-07-09 23:34:46 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2017-07-08 14:35:28 -0600

Seen: 2,729 times

Last updated: Jul 08 '17