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

use default arg in included file

asked 2019-11-22 17:03:18 -0500

acenturyandabit gravatar image

Say I have a number of launch files with arguments, like so:

//master.launch
<launch>
 <arg name="filename">
 <arg name="world" default="?????">
 <include file="${find package}/launch/$(arg filename).launch">
  <arg name="world" value="$(arg world)">
 </include>
</launch>

//child1.launch
<launch>
 <arg name="world" default="world1">
 <!-- do stuff -->
</launch>

//child2.launch
<launch>
 <arg name="world" default="world2">
 <!-- do stuff -->
</launch>

I want to set the world arg in master so that if I don't specify it, it will take the default in the child files.

However, the child defaults within each file are different, as you can see (world1 and world2).

How can i achieve this by replacing ????? ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-11-22 20:33:44 -0500

I want to set the world arg in master so that if I don't specify it, it will take the default in the child files.

Ok, so have a default in the parent file, lets continue...

However, the child defaults within each file are different, as you can see (world1 and world2).

Why not remove defaults entirely from the child launch files so they have no default options?

How can i achieve this by replacing ????? ?

Your options are to remove the defaults so they always take the parent's default (or given), or you have to homologate these yourself and make sure they're in sync.

edit flag offensive delete link more

Comments

So you're absolutely positive there's no "use-child-default" argument?... I think i'm seeing a potential solution here...

//child1.launch
<arg name="world" default="use-child-default"/>
<arg name="_world" if="$(eval world == 'use-child-default')" value="world1"/>
<arg name="_world" unless="$(eval world == 'use-child-default')" value="$(arg world)"/>

and then use _world...

acenturyandabit gravatar image acenturyandabit  ( 2019-11-23 15:12:14 -0500 )edit

I'm sure if you want to do some conditionals or add additional arguments, you could make it work out, but there's nothing out of the box that's going to solve your issue.

stevemacenski gravatar image stevemacenski  ( 2019-11-23 23:42:06 -0500 )edit

Question Tools

Stats

Asked: 2019-11-22 17:03:18 -0500

Seen: 102 times

Last updated: Nov 22 '19