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

How to set the parameter to let message_filters enter callback function

asked 2016-07-20 07:27:38 -0500

Nico.Zhou gravatar image

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!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-03-01 18:40:14 -0500

Jammy gravatar image

I am facing something similar...My callback function is not being called.. Any suggestions??

edit flag offensive delete link more

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.

AlexandreB gravatar image AlexandreB  ( 2017-03-01 19:22:09 -0500 )edit

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

Jammy gravatar image Jammy  ( 2017-03-01 20:13:31 -0500 )edit

What I want to know is how do I debug this issue and figure out the parameter values.

Jammy gravatar image Jammy  ( 2017-03-01 20:15:23 -0500 )edit

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.

Nico.Zhou gravatar image Nico.Zhou  ( 2017-03-01 21:24:34 -0500 )edit

You can check it on my github

Nico.Zhou gravatar image Nico.Zhou  ( 2017-03-01 21:25:30 -0500 )edit

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

Jammy gravatar image Jammy  ( 2017-03-01 21:47:44 -0500 )edit

Yes,I have done it with three topics before. It works fine.

Nico.Zhou gravatar image Nico.Zhou  ( 2017-03-01 22:08:19 -0500 )edit

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

AlexandreB gravatar image AlexandreB  ( 2017-03-02 09:21:26 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2016-07-20 07:27:38 -0500

Seen: 503 times

Last updated: Jul 20 '16