Ask Your Question
1

rosbag pause Marker disappears

asked 2017-11-08 11:07:13 -0500

tanasis gravatar image

updated 2017-12-06 08:58:56 -0500

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 flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2017-11-08 13:23:26 -0500

gvdhoorn gravatar image

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.

edit flag offensive delete link more
0

answered 2017-12-06 08:59:09 -0500

tanasis gravatar image

updated 2018-01-03 05:50:42 -0500

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

Comments

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

jayess gravatar imagejayess ( 2017-12-06 09:01:06 -0500 )edit

@jayess See edited answer ;)

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-11-08 11:07:13 -0500

Seen: 243 times

Last updated: Jan 03 '18