ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Perform calculation in .launch file

asked 2014-10-07 04:21:09 -0500

koenlek gravatar image

Hi all,

I wondered if it is possible to do a calculation in a roslaunch file, something like:

<arg name="windowsize" default="20"/>

<node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" output="screen" clear_params="true">
    <param name="xmin" value="$(arg -windowsize/2)" />
    <param name="ymin" value="$(arg  -windowsize/2)" />
    <param name="xmax" value="$(arg  windowsize/2)" />
    <param name="ymax" value="$(arg  windowsize/2)" />

I have tried several combinations, all without luck. And I can't seem to find anything about it on the web...

I really do need to be able to use the 'windowsize' argument, rather than 4 x/ymax/min arguments, to support some interface I made with other nodes I made...

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2017-01-01 11:36:57 -0500

VictorLamoine gravatar image

This is possible starting from Kinetic thanks to the eval keyword:

For example:

<param name="circumference" value="$(eval 2.* 3.1415 * arg('radius'))"/>

edit flag offensive delete link more


great! That's exactly what I was looking for.

koenlek gravatar image koenlek  ( 2017-01-02 04:48:06 -0500 )edit

answered 2014-10-07 18:19:51 -0500

ct2034 gravatar image

updated 2019-08-07 01:36:28 -0500

UPDATEThis changed in kinetic (see

As far as I am aware this wont be possible. The $(arg name)leads to substitution with the corresponding argument. But I think this only works for simple operations like replacements or logical decision lie if, unless.

edit flag offensive delete link more


This answer is not true anymore!

VictorLamoine gravatar image VictorLamoine  ( 2017-01-01 11:37:09 -0500 )edit

good news :)

ct2034 gravatar image ct2034  ( 2017-06-07 03:59:06 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2014-10-07 04:21:09 -0500

Seen: 2,546 times

Last updated: Aug 07 '19