# rosbag pause Marker disappears

Hello,

We have a node that publishes a set of markers. Those markers are part of sensor detections. So they can appear or disappear while the node is running, which is normal.

Now after doing a recording, we would like to pause the bag. When rosbag is on pause, all markers disappear. Programmatically all markers have a lifetime, such that they can be automatically removed. Is this the reason why markers also removed while on pause?

If yes, how is the right approach to solve this issue? Do I need to remove markers manually and not rely on lifetime?

Thanks!

edit retag close merge delete

Sort by » oldest newest most voted

Programmatically all markers have a lifetime, such that they can be automatically removed. Is this the reason why markers also removed while on pause?

yes, most likely. rosbag is no magic, it essentially just replays message traffic it has recorded. (Interactive) Markers are also just messages, so if those messages are played back by rosbag and they contain a lifetime setting other than ros::Duration() they will disappear.

If yes, how is the right approach to solve this issue? Do I need to remove markers manually and not rely on lifetime?

Well. Technically if you pause rosbag play I would expect time to also 'freeze', so perhaps markers with a timeout should not disappear. But that will depend on whether you are asking rosbag to also publish the clock.

If they still disappear with --clock after you've paused playback, that would perhaps be a bug and should be reported.

more

Indeed the lifecylce is causing the behavior, which means it is a no-go for my purpose.

The way I solved it currently, is to do a manual bookeeping of the markers that have been plotted and remove them just before the new set of markers need to be plotted.

I also use latched topics so that in a state of a pause, I can easily enable or disable marker's namespaces and in turn display or hide markers in rviz. Pretty cool :)

Edit 1: Here is a small code snippet:

// ros::Publisher rViz_target_markers_pub;
// visualization_msgs::MarkerArray target_marker_list;
void VizNode::ClearOldMarkers() {
is_clearing_old_data = true;
boost::lock_guard<boost::mutex> lock(marker_list_clear_mutex);
for (auto &marker : target_marker_list.markers) {
marker.action = visualization_msgs::Marker::DELETE;
marker.lifetime = ros::Duration(0.001); // just making sure! haha (probably overkill)
}
rViz_target_markers_pub.publish(target_marker_list);
target_marker_list.markers.clear();
is_clearing_old_data = false;
}


So the idea is the following:

1. You keep a the vector of markers you published (target_marker_list)
2. Before you post your new markers, you call ClearOldMarkers()
3. Then you post your new markers (clearing and re-using target_marker_list)
more

Do you have a short example of how you accomplished this?

( 2017-12-06 09:01:06 -0500 )edit

( 2018-01-03 05:51:04 -0500 )edit