Synchronise point Cloud and RGB Image from the same camera
Hello,
I possess a Xtion camera and I'm trying to retrieve the Point Cloud AND the rgb image at the same time through a Callback Function. I tried using message_filters to do this as such :
message_filters::Subscriber<sensor_msgs::PointCloud2> cloud_sub(nh, "/camera/depth/points_xyzrgb", 100);
message_filters::Subscriber<sensor_msgs::Image> image_sub(nh, "/camera/rgb/image", 100);
message_filters::TimeSynchronizer<sensor_msgs::PointCloud2, sensor_msgs::Image> sync(cloud_sub, image_sub, 10);
sync.registerCallback(boost::bind(&Main::doWork, main, _1, _2));
The code is working but since the message are not published at the exact same time (it is actually my guess of why the callback is never call), the Callback is never called and nothing happen.
My second idea would have been to store the rgb data each time the call back for this image is called and compared the time stamp of this image with the PointCloud one, for them not to be to far apart. But it's not a very elegant solution and I'm wondering if nothing better exist to do that in ROS. I would love to be able to give messages filter a space in which it can consider two messages to be published at the same time but I didn't find a way to do it in the doc.
I know already that I can find the rgb image from the pointCloud but the calculation are more intensive if I do it that way...
Thanks for you help and time !
Now I got the same problem.
The code is still working without error/warning, but I can not get any information. I checked the code and found the Callback is never called. Could you give me some suggestions?
Thanks!