Message filter using Approximate time policy. callback function called once.. [closed]
I want to access images and ultrasound reading from my ardrone parrot. To get readings in synchronized way i tried using message filter with approximate time policy.
image_transport::SubscriberFilter sub(it_,"/out_resize", 110);
message_filters::Subscriber<ardrone_autonomy::navdata_altitude> altitude_sub(nh,
"/ardrone/navdata_altitude", 100);
sync_policies::ApproximateTime<sensor_msgs::image,ardrone_autonomy::navdata_altitude> MySyncPolicy;
Synchronizer<mysyncpolicy> sync(MySyncPolicy(200),sub,altitude_sub);
sync.registerCallback(boost::bind(&VideoSource::callback,this, _1, _2));
Callback function
void VideoSource::callback(const sensor_msgs::ImageConstPtr& img_msg,const ardrone_autonomy::navdata_altitude::ConstPtr &msg)
{
fprintf(stderr,"inside\n");
alti_raw=*msg;
img = *img_msg;
is_frame_available = true;
}
This callback is only called once even though I am receiving continuous messages on both the topics. The difference between timestamps is around 100ms.
Can anyone tell me why this callback is getting called only once..
@sergey_alexandrov Thanks a lot man..declaring sync in constructor was the problem..
You may close the question so as to remove it from the "Unanswered" list and improve the overall statistics :)