Return a value from a <group>
If we have a launch file like this:
<launch>
<arg name="foo" value="2"/>
<group if="$(eval (foo == 1"))">
<arg name="bar" value="foo is one"/>
</group>
<group if="$(eval (foo == 2"))">
<arg name="bar" value="foo is two"/>
</group>
<group if="$(eval (foo == 3"))">
<arg name="bar" value="foo is three"/>
</group>
<!-- next line fails -->
<arg name="wibble" value="$(arg bar)"/>
</launch>
Basically I have a bunch of complicated logic that sets up a variable bar
, then from outside the <group>
scope I wish to access it again, rather than repeating all the logic. However, this gives the error:
arg 'bar' is not defined
Arg xml is <arg name="wibble" value="$(arg bar)"/>
I understand that <group>
opens a new scope, but is there a workaround for this? I could use <param>
to save bar
, but I cannot see a way to read it back from the parameter server.
Asked by KenYN on 2018-12-10 00:47:45 UTC
Comments
I assume this is a simplified example? As putting
if
andunless
directly onarg
elements is supported.Asked by gvdhoorn on 2018-12-10 01:34:29 UTC
Yes, it is simplified - I can of course do that, but there will be duplicated logic.
Asked by KenYN on 2018-12-10 01:48:44 UTC