0
$\begingroup$

Rosanswers logo

-------------------- SOLUTION ----------------- message_filters::TimeSynchronizer... has to be message_filters::Synchronizer... found that out after a day


How to mark as solved ?

Hi

I want to synchronize the image_color and the depth/image topic of a kinect.

both topics have different frequencies. i hoped before that they publish at the same time but sadly not.

is there a way to let these to topics been published simultaneously?


other posibility is to use a topic with rgb and d info, but i need an easy way to get the opencv rgb image.


the only topic i see, which has all info is "depth/points", but I need an opencv RGB image also, an iterative loop over the pointcloud to obtain the opencv image pixel by pixel seems to be studpi, because rgb image topic already exists.


why doesn'T that work:


private:
    message_filters::Subscriber image_sub;
    message_filters::Subscriber pointcloud_sub;

    message_filters::TimeSynchronizer synchronizer;

public :

    // Constructor
    VisualAidingOpenni()
        :  nh("~")/*, it(nh)*/, synchronizer(1), ....

private:
void a function ()... {

        image_sub.subscribe(nh, topic_image, 1);
        pointcloud_sub.subscribe(nh, topic_pointcloud, 1);
        synchronizer.connectInput(image_sub, pointcloud_sub);
        synchronizer.registerCallback(boost::bind(&VisualAidingOpenni::subscriber_Callback,this , _1, _2));
}


void  subscriber_Callback(const sensor_msgs::ImageConstPtr& msg, const sensor_msgs::ImageConstPtr& pointcloud)
    {

...
}

forget the word pointcloud, tried the depth image at last, so everything in sensor_msgs::image


this doesn't even compile


private:
    message_filters::Subscriber image_sub;
    message_filters::Subscriber pointcloud_sub;
    typedef sync_policies::ApproximateTime MySyncPolicy;
    message_filters::TimeSynchronizer synchronizer;

void function()
{
        image_sub = new message_filters::Subscriber(nh, topic_image, 1);
        pointcloud_sub = new message_filters::Subscriber(nh, topic_pointcloud, 1);
        synchronizer = new message_filters::TimeSynchronizer(MySyncPolicy(10), image_sub, pointcloud_sub);
 synchronizer.registerCallback(boost::bind(&VisualAidingOpenni::subscriber_Callback,this , _1, _2));

}

void  subscriber_Callback(const sensor_msgs::ImageConstPtr& msg, const sensor_msgs::ImageConstPtr& pointcloud)
    {

i get this error


/opt/hector/students/friedrich/hector_visual_aiding/hector_visaid_monocular/src/visual_aiding_openni.cpp:-1: In Elementfunktion »void VisualAidingOpenni::CamInfo_Callback(const CameraInfoConstPtr&)«:
:-1: Fehler:[CMakeFiles/visual_aiding_openni.dir/src/visual_aiding_openni.o] Fehler 1

THX


Originally posted by Pitscho on ROS Answers with karma: 36 on 2012-08-24

Post score: 0


Original comments

Comment by jbohren on 2012-08-24:
Shouldn't "mysyncpolicy" be "MySyncPolicy"?

Comment by Pitscho on 2012-08-24:
i have no idea why it isn't upper case here, but it is in qtcreator

Comment by jbohren on 2012-08-24:
Also could you post the error in a codeblock, it's getting mangled.

Comment by jbohren on 2012-08-24:
Yeah, there's no information on the error there.

Comment by Pitscho on 2012-08-24:
well, the error message just tells me in which function i have the error, nothing more-

Comment by Pitscho on 2012-08-24:
i installed 11.10 these days after i had ubuntu 12.04. since then my debugger information isn't as accurate as before, i don't know why. i use qtcreator. build type is debug.

Comment by jbohren on 2012-08-24:
The build type wouldn't affect compiler errors.

Comment by jbohren on 2012-08-24:
Can you try building it on the command line?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You can set up a callback in ROS that synchronizes messages from multiple topics with a TimeSynchronizer: http://www.ros.org/wiki/message_filters#Time_Synchronizer

As Dan Lazewatsky says in the comments below, if the timestamps aren't identical, then you might be able to use an ApproximateTimePolicy with the TimeSynchronizer.


Originally posted by jbohren with karma: 5809 on 2012-08-24

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Pitscho on 2012-08-24:
hi, i did that, but .. the two topics i subscribe publish in different frequencies. i need the rgb and d information as synchron as possible.

Comment by Pitscho on 2012-08-24:
/camera/rgb/image_color and /camera/depth_registered/image at the same time synchron would be perfect

Comment by Dan Lazewatsky on 2012-08-24:
Since the hardware doesn't synchronize the image acquisition, there is no way to get precisely synchronized images from a kinect. Using the ApproximateTime sync policy with a time synchronizer is probably your best option.

Comment by Pitscho on 2012-08-24:
so the data in /camera/depth/pointcloud with xyzrgb information is also not really synchron for positon and color ?

$\endgroup$

Your Answer

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