Skip to content

Commit

Permalink
Merge pull request #1138 from GiulioRomualdi/meshcat_delete_elements
Browse files Browse the repository at this point in the history
Add delete method to MeshcatVisualizer class
  • Loading branch information
traversaro authored Jan 5, 2024
2 parents ff85d7e + 435c6a3 commit 6fb96d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- CMake: Permit to explicitly specify Python installation directory by setting the `IDYNTREE_PYTHON_INSTALL_DIR` CMake variable (https://github.com/robotology/idyntree/pull/1124).

- MeshcatVisualizer: Add the possibility to remove a mesh from the visualizer (https://github.com/robotology/idyntree/pull/1138)

### Fixed

- Fixed compilation of pybind11 bindings (https://github.com/robotology/idyntree/pull/1128).
Expand Down
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 6fb96d9

Please sign in to comment.