Time Synchronizer (message_filters) with Custom Message type
Hi,
I want to have one callback function for subscription of two topics. I read online here that I can use the message_filters library to time synchronize the topics.
In my ROS node when I use the Image and Camera_info topic as suggested in the example code below, I get no errors.
message_filters::Subscriber<Image> image_sub(n, "image", 1);
message_filters::Subscriber<CameraInfo> info_sub(n, "camera_info", 1);
TimeSynchronizer<Image, CameraInfo> sync(image_sub, info_sub, 10);
sync.registerCallback(boost::bind(&callback, _1, _2));
But when I replace the Image and CameraInfo message formats with custom messages, as shown below, I get a lot of errors. I am attaching the
message_filters::Subscriber<coop_est::FeatureBArray> fea_sub(n, "Feature", 1);
message_filters::Subscriber<nav_msgs::Odometry> odo_sub(n, "odom", 1);
message_filters::TimeSynchronizer<coop_est::FeatureBArray, nav_msgs::Odometry> sync(fea_sub, odo_sub, 10);
sync.registerCallback(boost::bind(&FeaturesReceived, _1, _2));
Is message_filters time synchronizer only applicable to certain message formats ?
The error message I get it very long. I am pasting it here:
In file included from /opt/ros/hydro/include/message_filters/time_synchronizer.h:39:0,
from /home/quadrotor/catkin_ws/src/coop_est/src/coop_node.cpp:15:
/opt/ros/hydro/include/message_filters/sync_policies/exact_time.h: In member function ‘void message_filters::sync_policies::ExactTime<M0, M1, M2, M3, M4, M5, M6, M7, M8>::add(const typename boost::mpl::at_c<typename message_filters::PolicyBase<M0, M1, M2, M3, M4, M5, M6, M7, M8>::Events, i>::type&) [with int i = 0, M0 = coop_est::FeatureBArray_<std::allocator<void> >, M1 = nav_msgs::Odometry_<std::allocator<void> >, M2 = message_filters::NullType, M3 = message_filters::NullType, M4 = message_filters::NullType, M5 = message_filters::NullType, M6 = message_filters::NullType, M7 = message_filters::NullType, M8 = message_filters::NullType, typename boost::mpl::at_c<typename message_filters::PolicyBase<M0, M1, M2, M3, M4, M5, M6, M7, M8>::Events, i>::type = ros::MessageEvent<const coop_est::FeatureBArray_<std::allocator<void> > >]’:
/opt/ros/hydro/include/message_filters/synchronizer.h:358:5: instantiated from ‘void message_filters::Synchronizer<Policy>::cb(const typename boost::mpl::at_c<typename Policy::Events, i>::type&) [with int i = 0, Policy = message_filters::sync_policies::ExactTime<coop_est::FeatureBArray_<std::allocator<void> >, nav_msgs::Odometry_<std::allocator<void> >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>, typename boost::mpl::at_c<typename Policy::Events, i>::type = ros::MessageEvent<const coop_est::FeatureBArray_<std::allocator<void> > >]’
/opt/ros/hydro/include/message_filters/synchronizer.h:290:5: instantiated from ‘void message_filters::Synchronizer<Policy>::connectInput(F0&, F1&, F2&, F3&, F4&, F5&, F6&, F7&, F8&) [with F0 = message_filters::Subscriber<coop_est::FeatureBArray_<std::allocator<void> > >, F1 = message_filters::Subscriber<nav_msgs::Odometry_<std::allocator<void> > >, F2 = message_filters::NullFilter<message_filters::NullType>, F3 = message_filters::NullFilter<message_filters::NullType>, F4 = message_filters::NullFilter<message_filters::NullType>, F5 = message_filters::NullFilter<message_filters::NullType>, F6 = message_filters::NullFilter<message_filters::NullType>, F7 = message_filters::NullFilter<message_filters::NullType>, F8 = message_filters::NullFilter<message_filters::NullType>, Policy = message_filters::sync_policies::ExactTime<coop_est::FeatureBArray_<std::allocator<void> >, nav_msgs::Odometry_<std::allocator<void> >, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType, message_filters::NullType>]’
/opt/ros/hydro/include/message_filters/synchronizer.h:282:5: instantiated from ‘void message_filters::Synchronizer<Policy>::connectInput(F0&, F1&, F2&, F3&, F4&, F5&, F6&, F7&) [with F0 ...
TimeSynchronizer should work with any type that has a standard header. Can you post the error message?
Thank you for your reply kmhallen. I have edited the original question to include the error message.
I got the same synchrony problem with my custom message. and My message did has Header. part of error as follow: