2019-08-25 Ros下信息同步机制

Ros下信息同步主要用message_filter:

  message_filters::Subscriber pointsF_sub(nodeHandle_, "/velodyne1/velodyne_points", 1);
  message_filters::Subscriber pointsB_sub(nodeHandle_, "/velodyne2/velodyne_points", 1);

  //typedef sync_policies::ExactTime MySyncPolicy;
//精确时间同步
  // ExactTime takes a queue size as its constructor argument, hence MySyncPolicy(10)
//相似时间同步
  typedef message_filters::sync_policies::ApproximateTime MySyncPolicy;
  
  message_filters::Synchronizer sync(MySyncPolicy(10), pointsF_sub, pointsB_sub);
  sync.registerCallback(boost::bind(&ElevationMapping::pointCloudCallback, this, _1, _2));

void ElevationMapping::pointCloudCallback(
    const sensor_msgs::PointCloud2ConstPtr& Front_PointCloud, const sensor_msgs::PointCloud2ConstPtr& Back_PointCloud)
{
}

注意点:回调函数要用指针,参考内容:https://www.cnblogs.com/gdut-gordon/p/10293446.html

你可能感兴趣的:(2019-08-25 Ros下信息同步机制)