0
$\begingroup$

Rosanswers logo

Hi, I am trying to retrieve the mesh file names/paths from the robot URDF description. I seem to be able to get all of the other information (link name, mesh origin, parent/child link names, etc.).

Here is my code:

urdf::Model urdfModel;
if (!urdfModel.initParam("robot_description")) {
        ROS_ERROR("Error parsing URDF file...");
        return false;
}
string lnk_name = "/r2/left_palm";
boost::shared_ptr<urdf::Link> lnk;
urdfModel.getLink(lnk_name, lnk);

cout << "what is the type of model: " << viz->geometry->type << endl;
cout << viz->origin.position.x << endl;
cout << viz->origin.position.y << endl;
cout << viz->origin.position.z << endl;

That all works great, but I can't for the life of me figure out where the meshname is stored....

Thanks!


Originally posted by shart115 on ROS Answers with karma: 86 on 2012-09-14

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I haven't tried this out, but in general, it's under collision or visual geometry:

boost::dynamic_pointer_cast<const urdf::Mesh>(link->collision->geometry)->filename

Originally posted by hsu with karma: 5780 on 2012-09-14

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by shart115 on 2012-09-17:
Awesome, that works perfect. Thanks!

Comment by mkopack on 2012-10-16:
Could you guys please explain this a bit more. I'm utterly confused 1) how the example code in the quesiton could possibly work. Where is viz defined? 2) how this answer works... I don't get it at all. You're defining a dynamic pointer of type Mesh, but I don't get the rest...

Comment by mkopack on 2012-10-16:
Also doesn't help that the documentation for the urdf stuff is horribly lacking and has circular references. The example code only shows how to load it to be parsed, doesn't show how to access any of the data.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.