Ask Your Question
2

Parameters roslaunch from python script

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

Enriq gravatar image

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

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 imagelucasw ( 2018-06-19 16:04:39 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

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

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 imageEnriq ( 2017-07-09 06:12:56 -0500 )edit
1

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

Ed Venator gravatar imageEd Venator ( 2017-07-09 23:34:46 -0500 )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

2 followers

Stats

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

Seen: 1,310 times

Last updated: Jul 08 '17