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

URDF parser: How to get a cylinder's dimensions

asked 2014-10-30 14:07:06 -0600

NickDP gravatar image


I have a question that is probably fairly basic. I am parsing a .urdf robot model with the URDF parser. I am able to use this object to get info about my joints and links (masses, inertias etc).

I am now trying to get the length of a cylindrical link. I have a pointer to the link in question:

boost::shared_ptr<const urdf::Link> link;

This link has a cylindrical collision element. I can confirm this by checking that

link->collision->geometry->type == urdf::Geometry::CYLINDER

In the URDF documentation, I see a Cylinder class that inherits from the Geometry class. This Cylinder class has the member data length that I am looking for.

The problem is that I don't know how to access it.


won't compile, as link->collision->geometry is of type Geometry and not Cylinder.

I tried casting the boost::shared_ptr<urdf::Geometry> to boost::shared_ptr<urdf::Cylinder>, but that, too, won't compile.

How can I access the length member?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-03-21 13:04:31 -0600

Shishimy gravatar image


I suffered from same problem. I show you my solution by using pseudo code.

You can get pointer for a link by

#include <urdf/model.h>
urdf::Model model;
model.initParam(paramname);//Maybe you can use other init~ function.
boost::shared_ptr<const urdf::Link> link = model.getlink(linkname_on_urdf);
boost::shared_ptr<urdf::Cylinder> cylinder = 

you can access the length menber such as

double leng = cylinder->length;

This is my first posting. Sorry if there are something improper.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-10-30 14:07:06 -0600

Seen: 982 times

Last updated: Oct 30 '14