Ask Your Question
1

URDF parser: How to get a cylinder's dimensions

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

NickDP gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

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

Shishimy gravatar image

Hi

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 = 
boost::dynamic_pointer_cast<urdf::Cylinder>(link->visual->geometry);

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

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-10-30 14:07:06 -0500

Seen: 409 times

Last updated: Oct 30 '14