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

If statement in launch file

asked 2015-06-26 15:57:25 -0500

thailor3 gravatar image

I want to cancel the creation of a node in the launch file if a value, which is entered by user in console, equals a certain value. For instance

I am launching a file: roslaunch file attr1:='1' attr2:='2'

and in my launch file i want to do a check. the syntax in any other language would be :

if (attr1 == value){ cancel node};

problem is, in the launch file I tried to use a unless="$(arg attr1)" but it's not a bool because when i enter the value in the console, it is an int. So i realized the unless and if conditionals in the launch file are explicitly looking for a true or false, and that they can't do a comparison:

unless="$(arg attr1 == '1')"

did not work. any suggestions? Any syntax I can use launch file that would make this work?

THANKS!

edit retag flag offensive close merge delete

Comments

2

This question has already been asked at http://answers.ros.org/question/12756... BUT I'm wondering if (and very hopeful that) things have changed in Jade. See my comment on the accepted answer.

thebyohazard gravatar image thebyohazard  ( 2015-06-26 16:42:43 -0500 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2015-06-26 16:44:35 -0500

This is just not possible. The arg attr1 has to evaluate to true or false. This post is related: http://answers.ros.org/question/12756...

edit flag offensive delete link more
0

answered 2017-10-04 02:05:28 -0500

toblech gravatar image

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

edit flag offensive delete link more

Comments

1

@toblech Your sample code is not an example of the actual problem stated on the question. Also, are you sure is supported in Kinetic? I do not see that in the documentation, and haven't tried if using the new 'eval' works.

Javier V. Gómez gravatar image Javier V. Gómez  ( 2017-10-05 05:33:38 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-06-26 15:57:25 -0500

Seen: 13,947 times

Last updated: Oct 04 '17