Ask Your Question
0

Using pi in an URDF file

asked 2017-11-30 11:18:46 -0500

MatthiasLoebach gravatar image

We want to use the value of pi in an URDF file, since we have to rotate a model by 90 degrees. Is there any builtin macro for pi in URDF? At the moment we are simply using our own M_PI macro, but it would be nice to know what the intended way of doing such a thing would be.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2017-11-30 13:18:35 -0500

updated 2017-11-30 13:20:28 -0500

You can do this with xacro (a XML macro language): http://wiki.ros.org/xacro

From section 3. Math Expression

Since ROS Jade, Xacro employs python to evaluate expressions enclosed in dollared-braces (${}). This allows for more complex arithmetic expressions. Also, some basic constants, e.g. pi, are already predefined:

<xacro:property name="R" value="2" />
<xacro:property name="alpha" value="${30/180*pi}" />
<circle circumference="${2 * pi * R}" pos="${sin(alpha)} ${cos(alpha)}" />

You might be interested in the ROS xacro tutorial

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: 2017-11-30 11:18:46 -0500

Seen: 867 times

Last updated: Nov 30 '17