0
$\begingroup$

Rosanswers logo

I am using the roslaunch Python API to run some launch files. Some of these launch files have some arguments (specified with the arg tag). On the terminal, I would set these arguments like this:

roslaunch mypkg foobar.launch bla:=42

Unfortunately I am not able to figure out how to set the argument (bla:=42) when running the same launch file with the Python API.


Originally posted by Felix Widmaier on ROS Answers with karma: 382 on 2017-10-02

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

Hello,

After digging for a while, I believe it's not possible to set the arguments using the API.

There are related questions in this forum and seems that the users are using python subprocess to do that:

https://answers.ros.org/question/198910/how-to-set-args-with-python-roslaunch/ https://answers.ros.org/question/265796/parameters-roslaunch-from-python-script/

There's a page in ROS wiki as example, but without arguments: http://wiki.ros.org/roslaunch/API%20Usage

If you want to check by yourself, here goes the API page that refers to the launch object used in a ROS wiki:

http://docs.ros.org/indigo/api/roslaunch/html/roslaunch.parent.ROSLaunchParent-class.html

Fortunately, there's a Pull Request that proposes a solution to that issue:

https://github.com/ros/ros_comm/pull/1115

I hope it can help you!


Originally posted by marcoarruda with karma: 541 on 2017-10-02

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by Felix Widmaier on 2017-10-04:
Thanks for linking the pull request, I did not find that one.

Comment by Felix Widmaier on 2018-05-30:
Update: The linked pull request is merged for lunar (not backported to previous versions, though)

$\endgroup$
0
$\begingroup$

Rosanswers logo

As marcoarruda already wrote, there does not seem to be an option for this in the current API.

I checked the code of the roslaunch executable and found out, that they directly read the values from sys.argv. So a not very nice but working hack is to add arguments there before using roslaunch:

sys.argv.append("bla:=42")

Originally posted by Felix Widmaier with karma: 382 on 2017-10-04

This answer was NOT ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.