Skip to content

Commit

Permalink
Add delete method to MeshcatVisualizer class
Browse files Browse the repository at this point in the history
  • Loading branch information
GiulioRomualdi authored and flferretti committed Dec 23, 2024
1 parent 3e75c2b commit 3f27407
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions bindings/python/visualize/meshcat_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,3 +511,19 @@ def load_box(self, x, y, z, shape_name="iDynTree", color=None):
self.load_primitive_geometry(
solid_shape=box, shape_name=shape_name, color=color
)

def delete(self, shape_name="iDynTree"):
if self.__primitive_geometry_exists(shape_name):
self.viewer[shape_name].delete()
self.primitive_geometries_names.remove(shape_name)
elif self.__arrow_exists(shape_name):
self.viewer[shape_name].delete()
self.arrow_names.remove(shape_name)
elif self.__model_exists(shape_name):
self.viewer[shape_name].delete()
del self.model[shape_name]
del self.traversal[shape_name]
del self.link_pos[shape_name]
else:
msg = "The object named: " + name + " does not exist."
warnings.warn(msg, category=UserWarning, stacklevel=2)

0 comments on commit 3f27407

Please sign in to comment.