ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

I recommend to use DELETE_ALL, is simpler and no brute force is required. Here is a snippet:

from visualization_msgs.msg import Marker, MarkerArray
...
marker_array_msg = MarkerArray()
marker = Marker()
marker.id = 0
marker.ns = self.marker_ns
marker.action = Marker.DELETEALL
marker_array_msg.markers.append(marker)
self.marker_array_pub.publish(marker_array_msg)
rospy.sleep(0.2)