use default arg in included file
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 ????? ?
Asked by acenturyandabit on 2019-11-22 18:03:18 UTC
Answers
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.
Asked by stevemacenski on 2019-11-22 21:33:44 UTC
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...
Asked by acenturyandabit on 2019-11-23 16:12:14 UTC
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.
Asked by stevemacenski on 2019-11-24 00:42:06 UTC
Comments