Subscribing problem with message_filters
I've been trying to employ message_filters package to subscribe and synchronize multiple messages that are coming in. At this moment, I've been doing it for synchronizing only 2 topics. Nevertheless, the messages that are expected to come in do not appear to do so. I've tried to watch the string output(if it succeeds) via both console and rxconsole. I receive neither a single error nor warning for the time being.
Below, is my code snippet for it:
message_filters::Subscriber<sensor_msgs::LaserScan> scan_sub_(n, "/scan", 1);
message_filters::Subscriber<geometry_msgs::PoseStamped> poseLD_sub(n, "/pose3D_LD", 1);
TimeSynchronizer<sensor_msgs::LaserScan, geometry_msgs::PoseStamped> sync(scan_sub_, poseLD_sub, 10);
sync.registerCallback(boost::bind(&PointCloudBuilder::callback, this, _1, _2));
void PointCloudBuilder::callback(const sensor_msgs::LaserScanConstPtr& scan_ptr, const geometry_msgs::PoseStampedConstPtr& poseLD_ptr)
{
ROS_INFO("The data is coming in :-");
std::cout << "The data is coming in :-)" << std::endl;
std::cout << poseLD_ptr->pose.position.x << std::endl;
}
What could be the fix or how to debug it?
Thanks in advance.
EDIT
Should the published/incoming messages timestamps set as number 1 or 2, I'm a bit confused about this:
1. scan.header.stamp = ros::Time::now();
pose3D_LD.header.stamp = scan.header.stamp;
2. scan.header.stamp = ros::Time::now();
pose3D_LD.header.stamp = ros::Time::now();