Skip to content

Commit

Permalink
python/meshcat: fix loading of BVH model
Browse files Browse the repository at this point in the history
BVH models should be loaded in a raw manner after checking if they are not related to a specific file
  • Loading branch information
jcarpent committed Jul 16, 2021
1 parent 6f977ef commit 24dbede
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion bindings/python/pinocchio/visualize/meshcat_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ def loadPrimitive(self, geometry_object):

return obj

def isMesh(self, geometry_object):
""" Check whether the geometry object contains a Mesh supported by MeshCat """
if geometry_object.meshPath == "":
return False

_, file_extension = os.path.splitext(geometry_object.meshPath)
if file_extension.lower() in [".dae", ".obj", ".stl"]:
return True

return False

def loadMesh(self, geometry_object):

import meshcat.geometry
Expand Down Expand Up @@ -168,10 +179,14 @@ def loadViewerGeometryObject(self, geometry_object, geometry_type, color=None):
try:
if WITH_HPP_FCL_BINDINGS and isinstance(geometry_object.geometry, hppfcl.ShapeBase):
obj = self.loadPrimitive(geometry_object)
elif self.isMesh(geometry_object):
obj = self.loadMesh(geometry_object)
elif WITH_HPP_FCL_BINDINGS and isinstance(geometry_object.geometry, hppfcl.BVHModelBase):
obj = loadBVH(geometry_object.geometry)
else:
obj = self.loadMesh(geometry_object)
msg = "The geometry object named " + geometry_object.name + " is not supported by Pinocchio/MeshCat for vizualization."
warnings.warn(msg, category=UserWarning, stacklevel=2)
return
if obj is None:
return
except Exception as e:
Expand Down

0 comments on commit 24dbede

Please sign in to comment.