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

How to use eval in ROS2 XML launch file

asked 2020-11-26 05:13:16 -0600

nnmm gravatar image

updated 2020-11-26 07:07:22 -0600

As a minimal test case I wanted to do string concatenation inside a <let> tag: <let name="foo" value="$(eval 'a' + '_description')"/> returns

eval substitution expects 1 argument

Variable evaluation also doesn't work: $(eval var('bar')) prints

Expecting: {'RPAR', 'SPACE', 'DOLLAR', 'UNQUOTED_RSTRING'}

I assumed that this should be supported, because it says eval substitutions haven't changed in this official tutorial.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-09-13 20:14:56 -0600

eldeivid gravatar image

Based on a comment posted in the issue https://github.com/ros2/launch/issues/469, one way to make the eval substitution work is by adding extra quotes in the evaluated expression, as described below:

  <let name="foo" value="$(eval '\'a\' + \'_description\'')"/>

For the evaluation to work with a predefined variable, the expression would look like this (you will need to adapt for your own expression):

  <let name="bar" value="$(eval '\'$(var bar)\' == \'b\'')" />

I couldn't find any other documentation about this other than in the ticket mentioned above.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-11-26 05:13:16 -0600

Seen: 1,006 times

Last updated: Nov 26 '20