ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

roslaunch forwarding args to included launch file

asked 2015-11-02 06:27:19 -0600

Wolf gravatar image

Hi all,

I have a project with a couple of launch files. The head file, e. g.


includes the other launch files, e. g.

file_01.launch file_02.launch


Now, file_01.launch and file_02.launch may have arguments (with default values, of course but these shall be overridable via command line). I have found this is apparently only possible if the head launch file file_0.launch explicitly exposes the arg and passes it when including the other files, e. g.

<arg name="file_01_arg" default="false"/>
<include file="$(find my_package)/launch/file_01.launch" >
  <arg name="file_01_arg" value="$(arg  file_01_arg)"/>

However, this requires a lot of coding if an argument is changed somewhere in the launch tree. Is it possible to forward the arguments of included launch files without explicitly mentioning them in the including launch file?

edit retag flag offensive close merge delete


+1. I guess a feature idea for the same/similar situation is documented Add topic remapping to <include> tags...

130s gravatar image 130s  ( 2015-11-02 13:01:10 -0600 )edit

Yep, this was specifically proposed as "Bubbling up/passing through args" in the link @130s posted. There haven't been any takers to provide an implementation yet.

Dan Lazewatsky gravatar image Dan Lazewatsky  ( 2015-11-02 16:58:46 -0600 )edit

Finally a pull request is made.

130s gravatar image 130s  ( 2015-12-09 17:26:54 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-11-02 10:26:41 -0600

Dimitri Schachmann gravatar image

I fear there is no way with the <arg> tag only. Arguments are local to launch files. This has some advantages, I guess (like you know what arguments with what defaults are defined when looking at a launch file), but makes complex launch file structures cumbersome.

One thing you could do is use environment variables with $(env ENVIRONMENT_VARIABLE) or $(optenv ENVIRONMENT_VARIABLE default_value). See here.

Or you evaluate whether it is possible for you to use the parameter server in your nodes instead. There is a convenient syntax for setting those in a launch file:

 my_parameter_1: 768
 my_parameter_2: 480

Sadly this is often not an option with foreign nodes and I know of no way to query the parameter server in a launch file.

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



Asked: 2015-11-02 06:27:19 -0600

Seen: 1,930 times

Last updated: Nov 02 '15