Problem using callback with multiple arguments via ApproximateTime synchronizer
I have always no success in using callback with multiple arguments (in my use case here is three arguments) be it using exact time synchronizer or approximate one.
My implementation is like below:
void callback(const std_msgs::Float32::ConstPtr& msg1, const std_msgs::Float32::ConstPtr& msg2, const std_msgs::Float32::ConstPtr& msg3)
{
// some processing
}
message_filters::Subscriber<std_msgs::Float32> sub1(n, "chatter", 1);
message_filters::Subscriber<std_msgs::Float32> sub2(n, "chatter", 1);
message_filters::Subscriber<std_msgs::Float32> sub3(n, "chatter", 1);
typedef sync_policies::ApproximateTime<std_msgs::Float32, std_msgs::Float32, std_msgs::Float32> MySyncPolicy;
// ApproximateTime takes a queue size as its constructor argument, hence MySyncPolicy(10)
Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), sub1, sub2, sub3);
sync.registerCallback(boost::bind(&callback, _1, _2, _3));
Updated complete error:
{-------------------------------------------------------------------------------
/opt/ros/fuerte/include/message_filters/synchronizer.h:268:5: instantiated from ‘void message_filters::Synchronizer<Policy>::connectInput(F0&, F1&, F2&, F3&, F4&, F5&) [with F0 = message_filters::Subscriber<std_msgs::Float32_<std::allocator<void> > >, F1 = message_filters::Subscriber<std_msgs::Float32_<std::allocator<void> > >, F2 = message_filters::Subscriber<std_msgs::Float32_<std::allocator<void> > >, F3 = message_filters::NullFilter<message_filters::NullType>, F4 = message_filters::NullFilter<message_filters::NullType>, F5 = message_filters::NullFilter<message_filters::NullType>, Policy = message_filters::sync_policies::ApproximateTime<std_msgs::Float32_<std::allocator<void> >, std_msgs::Float32_<std::allocator<void> >, std_msgs::Float32_<std::allocator<void> > >]’/opt/ros/fuerte/include/message_filters/synchronizer.h:261:5: instantiated from ‘void message_filters::Synchronizer<Policy>::connectInput(F0&, F1&, F2&, F3&, F4&) [with F0 = message_filters::Subscriber<std_msgs::Float32_<std::allocator<void> > >, F1 = message_filters::Subscriber<std_msgs::Float32_<std::allocator<void> > >, F2 = message_filters::Subscriber<std_msgs::Float32_<std::allocator<void> > >, F3 = message_filters::NullFilter<message_filters::NullType>, F4 = message_filters::NullFilter<message_filters::NullType>, Policy = message_filters::sync_policies::ApproximateTime<std_msgs::Float32_<std::allocator<void> >, std_msgs::Float32_<std::allocator<void> >, std_msgs::Float32_<std::allocator<void> > >]’/opt/ros/fuerte/include/message_filters/synchronizer.h:254:5: instantiated from ‘void message_filters::Synchronizer<Policy>::connectInput(F0&, F1&, F2&, F3&) [with F0 = message_filters::Subscriber<std_msgs::Float32_<std::allocator<void> > >, F1 = message_filters::Subscriber<std_msgs::Float32_<std::allocator<void> > >, F2 = message_filters::Subscriber<std_msgs::Float32_<std::allocator<void> > >, F3 = message_filters::NullFilter<message_filters::NullType>, Policy = message_filters::sync_policies::ApproximateTime<std_msgs::Float32_<std::allocator<void> >, std_msgs::Float32_<std::allocator<void> >, std_msgs::Float32_<std::allocator<void> > >]’/opt/ros/fuerte/include/message_filters/synchronizer.h:247:5: instantiated from ‘void message_filters::Synchronizer<Policy>::connectInput(F0&, F1&, F2&) [with F0 = message_filters::Subscriber<std_msgs::Float32_<std::allocator<void> > >, F1 = message_filters::Subscriber<std_msgs::Float32_<std::allocator<void> > >, F2 = message_filters::Subscriber<std_msgs::Float32_<std::allocator<void> > >, Policy = message_filters::sync_policies::ApproximateTime<std_msgs::Float32_<std::allocator<void> >, std_msgs::Float32_<std::allocator<void> >, std_msgs::Float32_<std::allocator<void> > >]’/opt/ros/fuerte/include/message_filters/synchronizer.h:168:5: instantiated from ‘message_filters::Synchronizer<Policy>::Synchronizer(const Policy&, F0&, F1&, F2&) [with F0 = message_filters::Subscriber<std_msgs::Float32_<std::allocator<void> > >, F1 = message_filters::Subscriber<std_msgs::Float32_<std::allocator<void> > >, F2 = message_filters::Subscriber<std_msgs::Float32_<std::allocator<void> > >, Policy = message_filters::sync_policies::ApproximateTime<std_msgs::Float32_<std::allocator<void> >, std_msgs::Float32_<std::allocator<void> >, std_msgs::Float32_<std::allocator<void> > >]’/home/abc/ros_workspace/prototype/src/prototype_node.cpp:141:68: instantiated from here /opt/ros/fuerte/include/message_filters/sync_policies/approximate_time.h:620:119: error: ‘value’ is not a member of ‘ros::message_traits ...