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

How to set launch file arguments using roslaunch Python API

asked 2017-10-02 07:06:10 -0500

Felix Widmaier gravatar image

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.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2017-10-02 10:40:30 -0500

updated 2017-10-02 10:42:30 -0500


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:

There's a page in ROS wiki as example, but without arguments:

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

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

I hope it can help you!

edit flag offensive delete link more


Thanks for linking the pull request, I did not find that one.

Felix Widmaier gravatar image Felix Widmaier  ( 2017-10-04 02:15:54 -0500 )edit

Update: The linked pull request is merged for lunar (not backported to previous versions, though)

Felix Widmaier gravatar image Felix Widmaier  ( 2018-05-30 05:35:50 -0500 )edit

answered 2017-10-04 02:20:21 -0500

Felix Widmaier gravatar image

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:

edit flag offensive delete link more

Question Tools



Asked: 2017-10-02 07:06:10 -0500

Seen: 4,407 times

Last updated: Oct 04 '17