ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Subscribing problem with message_filters

asked 2012-01-28 23:16:56 -0500

alfa_80 gravatar image

updated 2012-01-29 01:36:52 -0500

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();
edit retag flag offensive close merge delete


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.
dornhege gravatar image dornhege  ( 2012-01-29 00:18:56 -0500 )edit
Strange, after retrying "1.", it still doesn't work.
alfa_80 gravatar image alfa_80  ( 2012-01-29 01:09:46 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2012-01-28 23:51:48 -0500

dornhege gravatar image

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

edit flag offensive delete link more


Yes, I think so, I have set the timestamps like the above update. I try one at a time. But, still doesn't work.
alfa_80 gravatar image alfa_80  ( 2012-01-29 00:10:54 -0500 )edit
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.
dornhege gravatar image dornhege  ( 2012-01-30 02:03:35 -0500 )edit

Question Tools


Asked: 2012-01-28 23:16:56 -0500

Seen: 1,407 times

Last updated: Jan 29 '12