From 9c4dfd13a572321c8c073662b5b51dda2ab86db4 Mon Sep 17 00:00:00 2001 From: Ludovica Danovaro <80389978+LudovicaDanovaro@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:01:45 +0100 Subject: [PATCH] Update meshcat_visualizer.py by adding set_property We changed this script by adding the function to set the "color" property in order to modify the color of a shape (such as a sphere) during the simulation. However it is impossible to change it in the animation --- bindings/python/visualize/meshcat_visualizer.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bindings/python/visualize/meshcat_visualizer.py b/bindings/python/visualize/meshcat_visualizer.py index 9a6633034c..a3b9e9a38b 100644 --- a/bindings/python/visualize/meshcat_visualizer.py +++ b/bindings/python/visualize/meshcat_visualizer.py @@ -581,6 +581,16 @@ def set_arrow_transform(self, origin, vector, shape_name="iDynTree"): with self._animation.at_frame(self.viewer, self._current_frame) as frame: frame[shape_name].set_transform(transform) + def set_primitive_geometry_property( + self, property_name, value, shape_name="iDynTree" + ): + if self.__primitive_geometry_exists(shape_name): + if self._animation is None: + self.viewer[shape_name].set_property(key=property_name, value=value) + else: + with self._animation.at_frame(self.viewer, self._current_frame) as frame: + raise NotImplementedError("The set_property method is not implemented for animations.") + def load_model_from_file( self, model_path: str, considered_joints=None, model_name="iDynTree", color=None ):