diff --git a/CHANGELOG.md b/CHANGELOG.md index 627e56f3d7..60dac6c9d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - Remove a lot of warnings ([#2139](https://github.com/stack-of-tasks/pinocchio/pull/2139)) +- `MeshcatVisualizer` doesn't crash anymore when there is no collision model defined ([#2147](https://github.com/stack-of-tasks/pinocchio/pull/2147)) ### Added - Add `examples/floating-base-velocity-viewer.py` to visualize floating base velocity [#2143](https://github.com/stack-of-tasks/pinocchio/pull/2143) diff --git a/bindings/python/pinocchio/visualize/meshcat_visualizer.py b/bindings/python/pinocchio/visualize/meshcat_visualizer.py index 4bf49884b5..eec47566f2 100644 --- a/bindings/python/pinocchio/visualize/meshcat_visualizer.py +++ b/bindings/python/pinocchio/visualize/meshcat_visualizer.py @@ -489,14 +489,16 @@ def loadViewerModel(self, rootNodeName="pinocchio", color=None): # Collisions self.viewerCollisionGroupName = self.viewerRootNodeName + "/" + "collisions" - for collision in self.collision_model.geometryObjects: - self.loadViewerGeometryObject(collision, pin.GeometryType.COLLISION, color) + if self.collision_model is not None: + for collision in self.collision_model.geometryObjects: + self.loadViewerGeometryObject(collision, pin.GeometryType.COLLISION, color) self.displayCollisions(False) # Visuals self.viewerVisualGroupName = self.viewerRootNodeName + "/" + "visuals" - for visual in self.visual_model.geometryObjects: - self.loadViewerGeometryObject(visual, pin.GeometryType.VISUAL, color) + if self.visual_model is not None: + for visual in self.visual_model.geometryObjects: + self.loadViewerGeometryObject(visual, pin.GeometryType.VISUAL, color) self.displayVisuals(True) # Frames