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

Perform calculation in .launch file

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

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)" />
</node>

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
5

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

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'))"/>

http://wiki.ros.org/roslaunch/XML#sub...

edit flag offensive delete link more

Comments

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

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

Works on Melodic as well as Noetic. Tried and tested ๐Ÿ‘๐Ÿป ... It is the correct way to do math operations in launch file

pranshu gravatar image pranshu  ( 2023-04-15 09:51:15 -0600 )edit
0

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

ct2034 gravatar image

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

UPDATEThis changed in kinetic (see http://answers.ros.org/question/19436...)

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. http://wiki.ros.org/roslaunch/XML

edit flag offensive delete link more

Comments

This answer is not true anymore!

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

good news :)

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

Question Tools

Stats

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

Seen: 2,959 times

Last updated: Aug 07 '19