rviz marker lifetime has no effect

asked 2017-05-28 03:05:56 -0500

ZOU Lu gravatar image

updated 2017-05-28 04:19:04 -0500


I'm trying to visualize some arbitrary number of markers. Markers were updated every 40ms, so I don't want them to persist on screen but rather have 40ms lifetime. However, the marker property 'lifetime' seems has no effect at all. Markers won't disappear automatically no matter how long I set the lifetime, like marker.lifetime = ros::Duration(0.04) or whatever time interval.

I know I could send a DELETE action to specific id that are no longer valid, or replace it with an empty marker. But it's tedious to keep track of how many markers I have, and DELETE ones that are not valid.

Am I doing something wrong? I modified the tutorial code Markers: Sending Basic Shapes (C++) like this: (changed to a unique id each time, and set the lifetime)

static uint32_t cnt = 0;
visualization_msgs::Marker marker;
// Set the frame ID and timestamp.  See the TF tutorials for information on these.
marker.header.frame_id = "/my_frame";
marker.header.stamp = ros::Time::now();

// Set the namespace and id for this marker.  This serves to create a unique ID
// Any marker sent with the same namespace and id will overwrite the old one
marker.ns = "basic_shapes";
marker.id = cnt++;
marker.lifetime = ros::Duration(0.01);

Thank you for any help!

edit retag flag offensive close merge delete


Not an expert, but did you see:

The countdown resets if another marker of the same namespace/id is received.

under Message Parameters?

gvdhoorn gravatar image gvdhoorn  ( 2017-05-28 03:12:21 -0500 )edit

Thank you!@gvdhoorn. I did missed that sentence. But I have tested with the modified tutorial code (with unique id), which has only one marker, and update once per second, so It won't reset the countdown if I set lifetime to 0.5 or less. But the marker still won't go away. How can you explain that?

ZOU Lu gravatar image ZOU Lu  ( 2017-05-28 04:03:36 -0500 )edit

I just wanted to draw your attention to that bit of documentation. Can't say why you're not observing what the rest of the documentation states should happen.

If you could create a MWE and post it as an issue on either the rviz or the interactive_markers repositories that could help.

gvdhoorn gravatar image gvdhoorn  ( 2017-05-28 04:43:54 -0500 )edit