How to set the parameter to let message_filters enter callback function
I want to use message_filters to get the image and imu message at the same time,but it's works sometimes because of different imu message frequency, I want to know how to set ApproximatePolicy param,here shows the code
message_filters::Subscriber<Image> image1_sub(nh, "/stereo/left/image_raw", 1);
message_filters::Subscriber<Image> image2_sub(nh, "/stereo/right/image_raw", 1);
message_filters::Subscriber<Imu> imu_sub(nh, "/inertial_tf/imu", 1);
message_filters::Subscriber<NavSatFix> gps_sub(nh, "/inertial_tf/gps", 1);
typedef ApproximateTime<Image, Image,Imu,NavSatFix> ApproximatePolicy;
typedef message_filters::Synchronizer<ApproximatePolicy> ApproximateSync;
boost::shared_ptr<ApproximateSync> approximate_sync_;
approximate_sync_.reset( new ApproximateSync(ApproximatePolicy(2000),
image1_sub, image2_sub,imu_sub,gps_sub) );
approximate_sync_->registerCallback(boost::bind(&imgimumsgFilter::callback,
&iif, _1, _2, _3, _4));
it works fine with this param when the frequency of image is 20Hz, and frequency of IMU is 100Hz, but when the frequency of IMU change to 60Hz,it did't work ,even I change the subscribe queue size and approximate time ,it is still didn't work and can't enter the callback function, so I want to know how to set this param correctly.Thanks!
Asked by Nico.Zhou on 2016-07-20 07:27:38 UTC
Answers
I am facing something similar...My callback function is not being called.. Any suggestions??
Asked by Jammy on 2017-03-01 19:40:14 UTC
Comments
Actually, I've determined that the issue what rosbag play did not display the correct rate. However, if you give me more details of your issue I may be able to help.
Asked by AlexandreB on 2017-03-01 20:22:09 UTC
So when I synchronize two topics it works. But when I try to synchronize 4 topics, callback is not called. The rate of all the topics that I am subscribing to is set to around 8 Hz.The two topics that have been added have timestamps and sequence ids but no frame ids but I guess it should not matter
Asked by Jammy on 2017-03-01 21:13:31 UTC
What I want to know is how do I debug this issue and figure out the parameter values.
Asked by Jammy on 2017-03-01 21:15:23 UTC
If the rate of all the topics is similar then the parameter values is not very important. The reason I fail to sync the data is I use the message filter in a wrong way. It works fine now after I change the code.
Asked by Nico.Zhou on 2017-03-01 22:24:34 UTC
Hi Nico, Thanks for the github link. I can see you synchronized 2 topics, but how did you do it for 4 topics like the original question you posted? I am able to do for 2 topics but not for more than 2
Asked by Jammy on 2017-03-01 22:47:44 UTC
Yes,I have done it with three topics before. It works fine.
Asked by Nico.Zhou on 2017-03-01 23:08:19 UTC
Uhm I would start my setting big buffers for the topics to be sure the algorithm receives at least on message of each type to syncronize
Asked by AlexandreB on 2017-03-02 10:21:26 UTC
Ok.. I figured out the problem. I just had to use image_transport Subscriber filter..Its working now..Thanks for the help guys..
Asked by Jammy on 2017-03-02 16:05:55 UTC
Comments