0
$\begingroup$

Rosanswers logo

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 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..


Originally posted by ayush_dewan on ROS Answers with karma: 1610 on 2013-06-09

Post score: 1


Original comments

Comment by ayush_dewan on 2013-06-09:
@sergey_alexandrov Thanks a lot man..declaring sync in constructor was the problem..

Comment by sergey_alexandrov on 2013-06-10:
You may close the question so as to remove it from the "Unanswered" list and improve the overall statistics :)

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Although you did not paste the complete listing, it seems like the sync object is not a member field of your VideoSource class, but rather a local variable (in constructor I guess). If this is the case then sync is destructed as soon as the constructor is executed, which removes the callback.


Originally posted by sergey_alexandrov with karma: 260 on 2013-06-09

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

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