ApproximateTimeSynchronizer does not trigger the callback function
I have checked with some related problems. Most of them are using the message_filter directly instead of approximateTimeSychronizer. However, even though I use the ApproximateTimeSynchronizer, my callback function can still not be called.
Specifically, I initially let my ros node subscribe two topic: /odom and /pc (PointCloud2). It works prettry well. I use another node to convert /pc into /aligned_pc, and let the previous node subscribe to /aligned_pc instead. It cannot work.
void callback(const OdometryConstPtr& odom, const PointCloud2ConstPtr& pc){
whatever...
}
Below is my main function
int main(int argc, char** argv){
ros::init(argc, argv, "sync");
//planner p;
ros::NodeHandle nh;
message_filters::Subscriber<nav_msgs::Odometry> odom_sub(nh, "odom", 100);
message_filters::Subscriber<sensor_msgs::PointCloud2> pc_sub(nh, "aligned_pc", 100);
typedef sync_policies::ApproximateTime<Odometry, PointCloud2> MySyncPolicy;
Synchronizer<MySyncPolicy> sync (MySyncPolicy(10), odom_sub, pc_sub);
sync.registerCallback(boost::bind(&callback, _1, _2));
ros::spin();
}