Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

URDF parser: How to get a cylinder's dimensions

Hi

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.

 link->collision->geometry->length

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?