Ask Your Question
0

How to set launch file arguments using roslaunch Python API

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

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
2

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

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

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/1989... https://answers.ros.org/question/2657...

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

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/roslau...

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

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

I hope it can help you!

edit flag offensive delete link more

Comments

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

Felix Widmaier gravatar imageFelix Widmaier ( 2017-10-04 02:15:54 -0600 )edit
4

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

Felix Widmaier gravatar imageFelix Widmaier ( 2018-05-30 05:35:50 -0600 )edit
2

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

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:

sys.argv.append("bla:=42")
edit flag offensive delete link more

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-10-02 07:06:10 -0600

Seen: 1,954 times

Last updated: Oct 04 '17