stack-of-tasks / pinocchio

A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
http://stack-of-tasks.github.io/pinocchio/
BSD 2-Clause "Simplified" License
1.95k stars 396 forks source link

buildModelsFromUrdf: ValueError: Mesh package could not be found #1639

Closed vassil-atn closed 2 years ago

vassil-atn commented 2 years ago

Hello,

I've been trying to get pinocchio (and gepetto-viewer) to work on a custom robot model (that of the Go1), but while the URDF gets loaded without a problem, when I try loading the mesh model get the following error:

model, collision_model, visual_model = pinocchio.buildModelsFromUrdf(urdf_model_path, mesh_dir)
>> ValueError: Mesh package://go1_description/meshes/trunk.dae could not be found.

For reference, I have sourced everything and added the "/opt/openrobots/share" to the ROS_PACKAGE_PATH. The other robots in the example-robot-data package load just fine. The meshes/ folder also contains all the necessary files (I believe):

ls /opt/openrobots/share/example-robot-data/robots/go1_description/meshes
>> calf.dae  depthCamera.dae  hip.dae  thigh.dae  thigh_mirror.dae  trunk.dae  ultraSound.dae

Do you know what could be causing this or how I could fix it? Is there anything else I need to set up to make it recognise the mesh files? Thanks!

jcarpent commented 2 years ago

You should export ROS_PACKAGE_PATH as /opt/openrobots/share/example-robot-data/robots or set mesh_dir=/opt/openrobots/share/example-robot-data/robots

vassil-atn commented 2 years ago

Thanks for the quick reply! I apologise, I should have included my directory code in the issue as well.

pinocchio_model_dir = join("/opt/openrobots", "share")
model_path = join(pinocchio_model_dir, "example-robot-data/robots")
mesh_dir = pinocchio_model_dir
urdf_filename = "a1.urdf"
urdf_model_path = join(join(model_path, "a1_description/urdf"), urdf_filename)

This works for the A1 robot, which is one of the example robots, it does not work for the Go1, however. Following your suggestion, changing the ROS_PACKAGE_PATH did not work but changing the mesh_dir did work:

pinocchio_model_dir = join("/opt/openrobots", "share")
model_path = join(pinocchio_model_dir, "example-robot-data/robots")
mesh_dir = model_path
urdf_filename = "go1.urdf"
urdf_model_path = join(join(model_path, "go1_description/urdf"), urdf_filename)

Changing the mesh_dir to the model_path works for the Go1 but not for the A1 (which now gives the ValueError).

Thanks again for solving the problem! I do wonder though why a different path for the mesh_dir needs to be specified for the two robots, even though the go1_description and a1_description are both subdirectories of example-robot-data/robots. Is there something I'm missing here, or is it maybe because one of them is a custom robot_description?

cmastalli commented 2 years ago

@Vassil17 would you be keen to integrate the standard Go1 in example-robot-data?

I would be more than happy if you help us with this ;)

jcarpent commented 2 years ago

Quick answer. There is no universal way to define the description of the robot. So, I would say that you should check the urdf path written in the urdf file.

vassil-atn commented 2 years ago

Thanks, I'll take a look at that!

@cmastalli As a disclaimer I'm just a master's student working with the Go1, however I would still be happy to help!

cmastalli commented 2 years ago

Thanks, I'll take a look at that!

@cmastalli As a disclaimer I'm just a master's student working with the Go1, however I would still be happy to help!

That's fine. We are happy to review your PR.