Parameters roslaunch from python script
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.
Asked by Enriq on 2017-07-08 14:35:28 UTC
Answers
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.
Asked by Ed Venator on 2017-07-08 19:43:51 UTC
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
Asked by Enriq on 2017-07-09 06:12:56 UTC
I think the problem is that Popen.communicate() blocks until the subprocess exits, and p4 never exits.
Asked by Ed Venator on 2017-07-09 23:34:46 UTC
Comments
lunar
(and presumablymelodic
and beyond) has the capability to have arguments now according to http://wiki.ros.org/roslaunch/API%20Usage#Roslaunch_file_with_command_line-style_arguments.It would be very convenient if it could be backported.
Asked by lucasw on 2018-06-19 16:04:39 UTC