From b367dc87c84006a2a2cd5dcb88348d678b516a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Caron?= Date: Thu, 1 Feb 2024 17:58:32 +0100 Subject: [PATCH 1/3] Don't iterate on collision geometries when undefined Closes https://github.com/stack-of-tasks/pinocchio/issues/2146 --- bindings/python/pinocchio/visualize/meshcat_visualizer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bindings/python/pinocchio/visualize/meshcat_visualizer.py b/bindings/python/pinocchio/visualize/meshcat_visualizer.py index 4bf49884b5..22e08e5d61 100644 --- a/bindings/python/pinocchio/visualize/meshcat_visualizer.py +++ b/bindings/python/pinocchio/visualize/meshcat_visualizer.py @@ -489,8 +489,9 @@ 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 From 3cfb273f662193f56a1d80757f008baa9b6b8bfc Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Fri, 2 Feb 2024 01:26:31 +0100 Subject: [PATCH 2/3] python/meshcat: fix also for no_visual --- bindings/python/pinocchio/visualize/meshcat_visualizer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bindings/python/pinocchio/visualize/meshcat_visualizer.py b/bindings/python/pinocchio/visualize/meshcat_visualizer.py index 22e08e5d61..eec47566f2 100644 --- a/bindings/python/pinocchio/visualize/meshcat_visualizer.py +++ b/bindings/python/pinocchio/visualize/meshcat_visualizer.py @@ -496,8 +496,9 @@ def loadViewerModel(self, rootNodeName="pinocchio", color=None): # 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 From 1f5755a622657b5e77d0b8211bbc8f2ad2fbdaa8 Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Fri, 2 Feb 2024 11:47:41 +0100 Subject: [PATCH 3/3] changelog: Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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)