clemense / yourdfpy

Python parser for URDFs
MIT License
122 stars 13 forks source link

ValueError on some models when meshes fail to load #8

Closed stephane-caron closed 2 years ago

stephane-caron commented 2 years ago

For instance on this model, yourdf yields the error below.

This is probably because the scene is empty when meshes are not found. (One symptom is that self._scene.bounds_corners is empty, thus its extents and scale cannot be computed.) If that's the case yourdf could report a more explicit error to users.

$ yourdfpy ./finger_edu.urdf
[2022-04-12 09:00:52] WARNING:yourdfpy.urdf:Unable to resolve filename: package://example-robot-data/robots/finger_edu_description/meshes/base_back.stl
[2022-04-12 09:00:52] WARNING:yourdfpy.urdf:Can't find package://example-robot-data/robots/finger_edu_description/meshes/base_back.stl
[2022-04-12 09:00:52] WARNING:yourdfpy.urdf:Unable to resolve filename: package://example-robot-data/robots/finger_edu_description/meshes/base_front.stl
[2022-04-12 09:00:52] WARNING:yourdfpy.urdf:Can't find package://example-robot-data/robots/finger_edu_description/meshes/base_front.stl
[2022-04-12 09:00:52] WARNING:yourdfpy.urdf:Unable to resolve filename: package://example-robot-data/robots/finger_edu_description/meshes/base_side_left.stl
[2022-04-12 09:00:52] WARNING:yourdfpy.urdf:Can't find package://example-robot-data/robots/finger_edu_description/meshes/base_side_left.stl
[2022-04-12 09:00:52] WARNING:yourdfpy.urdf:Unable to resolve filename: package://example-robot-data/robots/finger_edu_description/meshes/base_top.stl
[2022-04-12 09:00:52] WARNING:yourdfpy.urdf:Can't find package://example-robot-data/robots/finger_edu_description/meshes/base_top.stl
[2022-04-12 09:00:52] WARNING:yourdfpy.urdf:Unable to resolve filename: package://example-robot-data/robots/finger_edu_description/meshes/upper_link.stl
[2022-04-12 09:00:52] WARNING:yourdfpy.urdf:Can't find package://example-robot-data/robots/finger_edu_description/meshes/upper_link.stl
[2022-04-12 09:00:52] WARNING:yourdfpy.urdf:Unable to resolve filename: package://example-robot-data/robots/finger_edu_description/meshes/middle_link.stl
[2022-04-12 09:00:52] WARNING:yourdfpy.urdf:Can't find package://example-robot-data/robots/finger_edu_description/meshes/middle_link.stl
[2022-04-12 09:00:52] WARNING:yourdfpy.urdf:Unable to resolve filename: package://example-robot-data/robots/finger_edu_description/meshes/lower_link.stl
[2022-04-12 09:00:52] WARNING:yourdfpy.urdf:Can't find package://example-robot-data/robots/finger_edu_description/meshes/lower_link.stl
Traceback (most recent call last):
  File "/home/nelson/.local/bin/yourdfpy", line 8, in <module>
    sys.exit(run())
  File "/home/nelson/.local/lib/python3.8/site-packages/yourdfpy/viz.py", line 106, in run
    main(sys.argv[1:])
  File "/home/nelson/.local/lib/python3.8/site-packages/yourdfpy/viz.py", line 98, in main
    urdf_model.show(collision_geometry=args.collision)
  File "/home/nelson/.local/lib/python3.8/site-packages/yourdfpy/urdf.py", line 663, in show
    self._scene.show()
  File "/home/nelson/.local/lib/python3.8/site-packages/trimesh/scene/scene.py", line 1105, in show
    return SceneViewer(self, **kwargs)
  File "/home/nelson/.local/lib/python3.8/site-packages/trimesh/viewer/windowed.py", line 107, in __init__
    [0, 0, scene.scale / 1000 if self.offset_lines else 0])
  File "/home/nelson/.local/lib/python3.8/site-packages/trimesh/caching.py", line 109, in get_cached
    value = function(*args, **kwargs)
  File "/home/nelson/.local/lib/python3.8/site-packages/trimesh/scene/scene.py", line 384, in scale
    scale = (self.extents ** 2).sum() ** .5
  File "/home/nelson/.local/lib/python3.8/site-packages/trimesh/caching.py", line 109, in get_cached
    value = function(*args, **kwargs)
  File "/home/nelson/.local/lib/python3.8/site-packages/trimesh/scene/scene.py", line 372, in extents
    return np.diff(self.bounds, axis=0).reshape(-1)
  File "<__array_function__ internals>", line 5, in diff
  File "/home/nelson/.local/lib/python3.8/site-packages/numpy/lib/function_base.py", line 1258, in diff
    raise ValueError("diff requires input that is at least one dimensional")
ValueError: diff requires input that is at least one dimensional