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

Revision history [back]

click to hide/show revision 1
initial version

Since ROS Kinetic, there is a very neat solution for boolean operators in roslaunch file. See documentation. Here is an example for a "or" operation.

<arg name="cond_1" default="false"/> 
<arg name="cond_2" default="false"/>
<node pkg="PKG" type="TYPE" name="NAME" if="$(eval arg('cond_1) or arg('cond_2'))" />

This syntax can of course also be applied to including a launch file.

Use eval keyword.

Since ROS Kinetic, there is a very neat solution for boolean operators in roslaunch file. See documentation. Here is an example for a "or" operation.

<arg name="cond_1" default="false"/> 
<arg name="cond_2" default="false"/>
<node pkg="PKG" type="TYPE" name="NAME" if="$(eval arg('cond_1) or arg('cond_2'))" />

This syntax can of course also be applied to including a launch file.

Use eval keyword.

Since ROS Kinetic, there is a very neat solution for boolean operators in roslaunch file. See documentation. Here is an example for a "or" operation.

<arg name="cond_1" default="false"/> 
<arg name="cond_2" default="false"/>
<node pkg="PKG" type="TYPE" name="NAME" if="$(eval arg('cond_1) or arg('cond_2'))" />

This syntax can of course also be applied to including a launch file.

Thanks to @gvhoorn, I realized $(eval <expression>) allows to evaluate arbitrary complex python expressions.

Use eval keyword. keyword if you are using ROS Kinetic or newer version. See documentation.

Since ROS Kinetic, there This is a very neat solution for boolean operators in roslaunch file. See documentation. Here is an An example for a "or" operation. operation:

<arg name="cond_1" default="false"/> 
<arg name="cond_2" default="false"/>
<node pkg="PKG" type="TYPE" name="NAME" if="$(eval arg('cond_1) or arg('cond_2'))" />

This syntax can of course also be applied to including a launch file.

Thanks to @gvhoorn, I realized @gvhoorn's: $(eval <expression>) allows to evaluate arbitrary complex python expressions.

Use eval keyword if you are using ROS Kinetic or newer version. See documentation.

This is a very neat solution for boolean operators in roslaunch file. An example for a an "or" operation:

<arg name="cond_1" default="false"/> 
<arg name="cond_2" default="false"/>
<node pkg="PKG" type="TYPE" name="NAME" if="$(eval arg('cond_1) or arg('cond_2'))" />

This syntax can of course also be applied to including a launch file.

Thanks to @gvhoorn's: $(eval <expression>) allows to evaluate arbitrary complex python expressions.