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

clearing all markers / view in RVIZ remotely

asked 2013-01-28 22:53:00 -0600

Markus Achtelik gravatar image

Hi,

I'm drawing a lot of markers in rviz to visualize the outcome of an algorithm. As I'm often interrupting/killing it, it's infeasible to keep track of what has been drawn in order to delete it later. Is there any possibility to send something like "wipe" or "clear" to rviz to clear all markers? Currently, I'm sending a message with many markers with action=DELETE but that seems a bit brute force. Is there any better option?

Thanks a lot!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-01-29 04:25:29 -0600

joq gravatar image

If you are setting markers fairly frequently, perhaps you could set an appropriate lifetime in the Marker message.

Then, rviz would erase them after you kill your node.

edit flag offensive delete link more

Comments

Thanks, that could be a workaround. I Just have to think about something when I get a coffee and the algorithm finished in the meantime... ;) It seems there is no other solution (yet)?

Markus Achtelik gravatar image Markus Achtelik  ( 2013-01-30 04:26:40 -0600 )edit
2

The usual solution is to re-use the marker.ns and marker.id values of the obsolete markers, which automatically deletes them as a side-effect.

joq gravatar image joq  ( 2013-01-30 04:31:40 -0600 )edit
2

answered 2021-04-06 23:19:16 -0600

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)
edit flag offensive delete link more

Comments

This solution is especially helpful if the number of markers in the array changes from message to message because the 're-using marker.id' solution from the comment above can't be applied in this case.

labude gravatar image labude  ( 2023-03-12 08:08:53 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-01-28 22:53:00 -0600

Seen: 10,475 times

Last updated: Apr 06 '21