Skip to content

Commit

Permalink
Update meshcat_visualizer.py by adding set_property (#1225)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
LudovicaDanovaro authored Jan 10, 2025
1 parent 5ea59c9 commit fcd3d6b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bindings/python/visualize/meshcat_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
):
Expand Down

0 comments on commit fcd3d6b

Please sign in to comment.