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

Message filter using Approximate time policy. callback function called once.. [closed]

asked 2013-06-09 02:50:02 -0500

updated 2014-01-28 17:16:49 -0500

ngrennan gravatar image

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

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by ayush_dewan
close date 2013-06-10 16:13:07

Comments

@sergey_alexandrov Thanks a lot man..declaring sync in constructor was the problem..

ayush_dewan gravatar image ayush_dewan  ( 2013-06-09 09:40:33 -0500 )edit

You may close the question so as to remove it from the "Unanswered" list and improve the overall statistics :)

sergey_alexandrov gravatar image sergey_alexandrov  ( 2013-06-10 12:54:35 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-06-09 03:23:25 -0500

sergey_alexandrov gravatar image

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.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-06-09 02:50:02 -0500

Seen: 1,896 times

Last updated: Jun 09 '13