Rosanswers logo

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.


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();

Originally posted by alfa_80 on ROS Answers with karma: 1053 on 2012-01-29

Post score: 0

Original comments

Comment by alfa_80 on 2012-01-29:
Strange, after retrying "1.", it still doesn't work.

Comment by dornhege on 2012-01-29:\

  1. should work, 2. would give similar but not the same timestamps. But, if you can do 1., you already have the messages synched at this spot and could call the funciton from here.

1 Answer 1


Rosanswers logo

Do the two incoming topics have EXACTLY the same timestamps? Only then, the timesynchronizer will work. Otherwise you need to use ApproximateTimePolicy.

Originally posted by dornhege with karma: 31395 on 2012-01-29

This answer was ACCEPTED on the original site

Post score: 2

Original comments

Comment by dornhege on 2012-01-30:
Maybe you can check with rostopic echo for the headers of both messages. If they are send with the same timestamps, and not going of of the queue, you should get a callback.

Comment by alfa_80 on 2012-01-29:
Yes, I think so, I have set the timestamps like the above update. I try one at a time. But, still doesn't work.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.