Ask Your Question
0

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

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

lucasw gravatar image

updated 2014-01-06 12:57:45 -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
1

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::macro>

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

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

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

Seen: 836 times

Last updated: Jan 07 '14