Skip to content

Commit fcd3d6b

Browse files
Update meshcat_visualizer.py by adding set_property (#1225)
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
1 parent 5ea59c9 commit fcd3d6b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

bindings/python/visualize/meshcat_visualizer.py

+10
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,16 @@ def set_arrow_transform(self, origin, vector, shape_name="iDynTree"):
581581
with self._animation.at_frame(self.viewer, self._current_frame) as frame:
582582
frame[shape_name].set_transform(transform)
583583

584+
def set_primitive_geometry_property(
585+
self, property_name, value, shape_name="iDynTree"
586+
):
587+
if self.__primitive_geometry_exists(shape_name):
588+
if self._animation is None:
589+
self.viewer[shape_name].set_property(key=property_name, value=value)
590+
else:
591+
with self._animation.at_frame(self.viewer, self._current_frame) as frame:
592+
raise NotImplementedError("The set_property method is not implemented for animations.")
593+
584594
def load_model_from_file(
585595
self, model_path: str, considered_joints=None, model_name="iDynTree", color=None
586596
):

0 commit comments

Comments
 (0)