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

xacro arg to xacro:property, or math on xacro args?

asked 2014-01-06 12:56:36 -0500

lucasw gravatar image

updated 2020-11-21 11:36:14 -0500

Should it be possible to set a xacro property with a value passed in as an argument?

<xacro:property name="length" value=$(arg length_arg)" />

Right now I get:

ValueError: could not convert string to float: $(arg chassis_length_arg)

I'd like to be able to do math on xacro arguments, but

${$(arg length_arg) / 2}

also doesn't work so there appears to be no way to do it other than precomputing the right values and passing them in as args.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-01-07 12:15:17 -0500

lucasw gravatar image

It just now occurred to me that the solution is to make a xacro macro wrap all the math on the arguments and the call to the macro reference the arg:

 <xacro:macro name="foo" params="chassis_length" >
     ... do something with ${chassis_length/2}

 <xacro:foo chassis_length="$(arg chassis_length)">
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-01-06 12:56:36 -0500

Seen: 1,964 times

Last updated: Jan 07 '14