diff --git a/include/rviz_visual_tools/rviz_visual_tools.h b/include/rviz_visual_tools/rviz_visual_tools.h index 8245b82..05de738 100644 --- a/include/rviz_visual_tools/rviz_visual_tools.h +++ b/include/rviz_visual_tools/rviz_visual_tools.h @@ -217,6 +217,11 @@ class RvizVisualTools */ void resetMarkerCounts(); + /** + * \brief Remove a specific marker with the given id. + */ + void removeMarkerWithID(int id); + /** * \brief Pre-load rviz markers for better efficiency * \return converted pose * \return true on sucess diff --git a/src/rviz_visual_tools.cpp b/src/rviz_visual_tools.cpp index 30f7676..7abdced 100644 --- a/src/rviz_visual_tools.cpp +++ b/src/rviz_visual_tools.cpp @@ -80,6 +80,21 @@ bool RvizVisualTools::deleteAllMarkers() return publishMarker(reset_marker_); } +void RvizVisualTools::removeMarkerWithID(int id) +{ + visualization_msgs::Marker empty_marker; + empty_marker.header.frame_id = base_frame_; + empty_marker.id = id; + empty_marker.header.stamp = ros::Time(); + empty_marker.ns = "deleteAllMarkers"; + empty_marker.action = 3; + empty_marker.pose.orientation.w = 1; + + visualization_msgs::MarkerArray empty_marker_array; + empty_marker_array.markers.push_back(empty_marker); + pub_rviz_markers_.publish(empty_marker_array); +} + void RvizVisualTools::resetMarkerCounts() { arrow_marker_.id++;