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

roslaunch forwarding args to included launch file

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

Wolf gravatar image

Hi all,

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

file_0.launch

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)"/>
 </include>

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

Comments

+1. I guess a feature idea for the same/similar situation is documented http://wiki.ros.org/sig/roslaunch#Pro... Add topic remapping to <include> tags...

130s gravatar image 130s  ( 2015-11-02 13:01:10 -0500 )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 -0500 )edit
1

Finally a pull request is made.

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

1 Answer

Sort by ยป oldest newest most voted
2

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

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:

<rosparam>
 my_parameter_1: 768
 my_parameter_2: 480
</rosparam>

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

Question Tools

2 followers

Stats

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

Seen: 2,104 times

Last updated: Nov 02 '15