1
$\begingroup$

Rosanswers logo

How can say: run this node if argX==y

The following does not work, and the documentation on this is lacking.

<node pkg="xxx" type="yyy" name="yyy" if="$(arg argX)==y" />

Originally posted by Yogi on ROS Answers with karma: 411 on 2012-01-25

Post score: 13

$\endgroup$

4 Answers 4

0
$\begingroup$

Rosanswers logo

You can do this now in ROS Kinetic using eval:

<arg name="arg_name" default="desired_value"/>

<node pkg="node_pkg" type="node_type" name="node_name" 
      if="$(eval arg('arg_name') == 'desired_value')"/>

The documentation has been updated: http://wiki.ros.org/roslaunch/XML


Originally posted by adamconkey with karma: 642 on 2017-10-09

This answer was ACCEPTED on the original site

Post score: 34


Original comments

Comment by limitless on 2017-12-02:

  <group if="$(eval arg('debug') ==0)">
    <node pkg="xxx" type="yyy" name="yyy">
  </group>

Comment by Markus on 2019-03-15:

worked for me. The above did not work for me.

Comment by 130s on 2021-05-25:
Updated the answer's description based on @limitless and @Markus' comments.

$\endgroup$
0
$\begingroup$

Rosanswers logo

The documentation on the roslaunch page for this syntax is complete, i.e. you can't do comparisons or any operators for that matter. You can only test the value itself.


Originally posted by kwc with karma: 12244 on 2012-01-25

This answer was NOT ACCEPTED on the original site

Post score: 8


Original comments

Comment by Kei Okada on 2012-05-10:
link to the documentation --- http://ros.org/wiki/roslaunch/XML

$\endgroup$
0
$\begingroup$

Rosanswers logo

Is this answer still current? I see that xacro got an upgrade: from http://wiki.ros.org/xacro#Conditional_Blocks "The more powerful evaluation capabilities in ROS Jade allow for much more complex expression. Virtually any python expression that evaluates to a Boolean is feasible."

EDIT 2015.6.30:

I found a related ticket suggesting that Ken's answer is probably still current, though I don't yet have jade to check for sure.


Originally posted by thebyohazard with karma: 3562 on 2015-06-25

This answer was NOT ACCEPTED on the original site

Post score: 2

$\endgroup$
0
$\begingroup$

Rosanswers logo

This is supported as of ROS Kinetic.

<group if="$(arg foo)">
  <!-- stuff that will only be evaluated if foo is true -->
</group>

See also http://wiki.ros.org/roslaunch/XML


Originally posted by toblech with karma: 86 on 2017-10-04

This answer was NOT ACCEPTED on the original site

Post score: 4


Original comments

Comment by Felix Widmaier on 2018-01-31:
This does not answer the question which is about comparing foo to some arbitrary (non-bool) value.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.