Ros下信息同步主要用message_filter:
message_filters::Subscriber<sensor_msgs::PointCloud2> pointsF_sub(nodeHandle_, "/velodyne1/velodyne_points", 1);
message_filters::Subscriber<sensor_msgs::PointCloud2> pointsB_sub(nodeHandle_, "/velodyne2/velodyne_points", 1);
//typedef sync_policies::ExactTime<sensor_msgs::PointCloud2, sensor_msgs::PointCloud2> MySyncPolicy;
//精确时间同步
// ExactTime takes a queue size as its constructor argument, hence MySyncPolicy(10)
//相似时间同步
typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::PointCloud2, sensor_msgs::PointCloud2> MySyncPolicy;
message_filters::Synchronizer<MySyncPolicy> 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
网友评论