Skip to content

Commit

Permalink
Merge pull request #398 from iory/urdf
Browse files Browse the repository at this point in the history
Handle missing nodes gracefully and update geometry parsing logic in …
  • Loading branch information
iory authored Oct 27, 2024
2 parents 0376a71 + 409545c commit 3ac3848
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions skrobot/utils/urdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,8 @@ def _parse(cls, node, path):
and elements in the class arrays.
"""
kwargs = cls._parse_simple_attribs(node)
kwargs.update(cls._parse_simple_elements(node, path))
if node is not None:
kwargs.update(cls._parse_simple_elements(node, path))
return kwargs

@classmethod
Expand Down Expand Up @@ -958,9 +959,9 @@ class Geometry(URDFType):
_TAG = 'geometry'

def __init__(self, box=None, cylinder=None, sphere=None, mesh=None):
if (box is None and cylinder is None
and sphere is None and mesh is None):
raise ValueError('At least one geometry element must be set')
# if (box is None and cylinder is None
# and sphere is None and mesh is None):
# raise ValueError('At least one geometry element must be set')
self.box = box
self.cylinder = cylinder
self.sphere = sphere
Expand Down Expand Up @@ -1042,7 +1043,10 @@ def meshes(self):
list of :class:`~trimesh.base.Trimesh` : The geometry's triangular
mesh representation(s).
"""
return self.geometry.meshes
geo = self.geometry
if geo is None:
return []
return geo.meshes


class Texture(URDFType):
Expand Down

0 comments on commit 3ac3848

Please sign in to comment.