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

Using pi in an URDF file

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

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
8

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

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

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

Question Tools

1 follower

Stats

Asked: 2017-11-30 11:18:46 -0600

Seen: 5,421 times

Last updated: Nov 30 '17