eval command isn't working in arg tag inside roslaunch
I am using ROS Melodic and trying to use eval command inside arg with a decision-making statement. Please see the following code snippet from roslaunch file:
<arg name="mode" default="sim" doc="operating mode of the system. only real and sim are supported." />
<arg if="$(eval mode == 'sim')" name="robot_ip" value="127.0.0.1" />
<arg unless="$(eval mode == 'real')" name="robot_ip" value="192.168.10.10" />
The above roslaunch is not working and throwing an exception by saying that robot_ip must be defined.
In contrast, if we have a boolean, it can be used easily as shown below:
<arg name="debug" default="false" />
<arg if="$(arg debug)" name="launch_prefix" value="gdb -ex run --args" />
<arg unless="$(arg debug)" name="launch_prefix" value="" />
Any workaround for using non-boolean variable, please?
I just realized a mistake in above code. All I need to do is change to
unless
toif
like the following<arg unless="$(eval mode == 'real')"
and it works well. Thank you very much.