Robotics StackExchange | Archived questions

not able to clear markers from the MarkerArray()

I have a vertice and edge structure implemented within a python script and everytime I want to delete a node and the edge I am able to delete it visually but it is still getting published to the length of the MarkerArray(). The problem is, if the length of the array keeps on increasing, rviz begins to lag so much that I have no option but to shut it down as the length goes upto more than 10000. I am a newbie and I could not find a relevant tutorial for this. I have attached the piece of code below for reference.

Is there a way to actually clear the markers from the array as well? Also, using self.normal_marker_array.markers.clear() does not seem to do the job. I am still pretty new to this so any help would be much appreciated

def removeVertexMarker(self, vid):
marker = Marker()
marker.header.frame_id = 'map'
marker.id = vid
marker.ns = "vertices"  
marker.action = 2
self.normal_marker_array.markers.append(marker)
self.normal_marker_array_update = True

def removeEdgeMarker(self, eid):
marker = Marker()
marker.header.frame_id = 'map'
marker.id = eid
marker.ns = "edges"
marker.action = 2
self.normal_marker_array.markers.append(marker)
self.normal_marker_array_update = True

Asked by kzrthzk on 2022-08-19 07:38:45 UTC

Comments

Answers