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

RobotWrapper.BuildFromURDF(URDF), ValueError: Mesh file could not be found. #1477

Closed beta1scat closed 3 years ago

beta1scat commented 3 years ago

System: Ubuntu 18.04 ROS: Melodic Pinocchio: robotpkg-py36-pinocchio

I am learning Pinocchio tutorials: https://gepettoweb.laas.fr/doc/stack-of-tasks/pinocchio/master/doxygen-html/md_doc_d-practical-exercises_1-directgeom.html

I have cloned package "example-robot-data" from https://github.com/Gepetto/example-robot-data in my ROS catkin workspace and build successed. But when I want to use URDF file in ROS package "example-robot-data" with my python scripts, an error occered: ValueError: Mesh package://example-robot-data/robots/solo_description/meshes/obj/with_foot/solo_body.obj could not be found.

My scripts is :

from pinocchio.robot_wrapper import RobotWrapper

URDF = '/home/niu/catkin_ws/src/example-robot-data/robots/ur_description/urdf/ur5_robot.urdf'
robot = RobotWrapper.BuildFromURDF(URDF)
for name, function in robot.model.__class__.__dict__.items():
    print(' **** %s: %s' % (name, function.__doc__))

I have sourced: devel/setup.bash and ROS_PACKAGE_PATH is OK. My ~/.bashrc file is:

export PATH=/opt/openrobots/bin:$PATH
export PKG_CONFIG_PATH=/opt/openrobots/lib/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=/opt/openrobots/lib:$LD_LIBRARY_PATH
export PYTHONPATH=/opt/openrobots/lib/python3.6/site-packages:$PYTHONPATH # Adapt your desired python version here
export CMAKE_PREFIX_PATH=/opt/openrobots:$CMAKE_PREFIX_PATH
source /opt/ros/melodic/setup.bash
source /home/niu/catkin_ws/devel/setup.bash

ROS_PACKAGE_PATH: ROS_PACKAGE_PATH=/home/niu/catkin_ws/src/example-robot-data:/opt/ros/melodic/share

beta1scat commented 3 years ago

When I use model = pin.buildModelFromUrdf(URDF) there is no error.

jcarpent commented 3 years ago

@proyan Could you help on this?

jcarpent commented 3 years ago

I think ROS_PACKAGE_PATH=/home/niu/catkin_ws/src should make the job.

nim65s commented 3 years ago

Hi @beta1scat,

The point of example robot data is to allow an easy

from example_robot_data import load
robot = load('ur5')

Wouldn't this suit your needs ?

jcarpent commented 3 years ago

You can also precise the package dirs as follows:

robot = RobotWrapper.BuildFromURDF(URDF,package_dirs=['/home/niu/catkin_ws/src'])

I will close as the problem will be solved from mines or @nim65s' suggestions

beta1scat commented 3 years ago

Thank you very much! @jcarpent @nim65s All your methods are OK!