Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

errors while using cache filter in message_filters

I am trying to access historical data generated by lidar over multiple frames. Based on some suggestion, I was trying to use cache filter to solve it. Eventually, got lot of errors and could not figure out the particular error source. Following is the code;

message_filters::Cache<sensor_msgs::PointCloud2> cache;
    void pcl_history_caller(const sensor_msgs::PointCloud2::ConstPtr &cloud_data)
    {
      cache.add(cloud_data);
      std::vector<sensor_msgs::PointCloud2::ConstPtr> interval_1 = cache.getInterval(cache.getOldestTime(), cache.getLatestTime());
    // do some stuff here using  cache here

    }

    int main(int argc, char** argv)
    {
        ros::init(argc, argv, "cache_node");
        ros::NodeHandle nh;
        message_filters::Subscriber<sensor_msgs::PointCloud2> pcl_history(nh, "hokuyo_points", 1);
        cache(pcl_history, 100);
        cache.registerCallback((boost::bind(&pcl_history_caller), _1));


 ros::spin();
    return 0;
}
`

Following are the errors;

    /home/anindya/catkin_ws/src/spin_hokuyo/src/sensor_task.cpp: In function ‘int main(int, char**)’:
        /home/anindya/catkin_ws/src/spin_hokuyo/src/sensor_task.cpp:88:27: error: no match for call to ‘(message_filters::Cache<sensor_msgs::PointCloud2_<std::allocator<void> > >) (message_filters::Subscriber<sensor_msgs::PointCloud2_<std::allocator<void> > >&, int)’
             cache(pcl_history, 100);
                                   ^
        In file included from /usr/include/boost/bind.hpp:22:0,
                         from /opt/ros/indigo/include/ros/publisher.h:35,
                         from /opt/ros/indigo/include/ros/node_handle.h:32,
                         from /opt/ros/indigo/include/ros/ros.h:45,
                         from /home/anindya/catkin_ws/src/spin_hokuyo/src/sensor_task.cpp:17:
        /usr/include/boost/bind/bind.hpp: In instantiation of ‘struct boost::_bi::result_traits<boost::_bi::unspecified, void (*)(const boost::shared_ptr<const sensor_msgs::PointCloud2_<std::allocator<void> > >&)>’:
        /usr/include/boost/bind/bind_template.hpp:15:48:   required from ‘class boost::_bi::bind_t<boost::_bi::unspecified, void (*)(const boost::shared_ptr<const sensor_msgs::PointCloud2_<std::allocator<void> > >&), boost::_bi::list0>’
        /home/anindya/catkin_ws/src/spin_hokuyo/src/sensor_task.cpp:89:60:   required from here
        /usr/include/boost/bind/bind.hpp:69:37: error: ‘void (*)(const boost::shared_ptr<const sensor_msgs::PointCloud2_<std::allocator<void> > >&)’ is not a class, struct, or union type
             typedef typename F::result_type type;
                                             ^
        In file included from /usr/include/boost/function/detail/maybe_include.hpp:18:0,
                         from /usr/include/boost/function/detail/function_iterate.hpp:14,
                         from /usr/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:52,
                         from /usr/include/boost/function.hpp:64,
                         from /opt/ros/indigo/include/ros/forwards.h:40,
                         from /opt/ros/indigo/include/ros/common.h:37,
                         from /opt/ros/indigo/include/ros/ros.h:43,
                         from /home/anindya/catkin_ws/src/spin_hokuyo/src/sensor_task.cpp:17:
        /usr/include/boost/function/function_template.hpp: In instantiation of ‘static void boost::detail::function::void_function_obj_invoker1<FunctionObj, R, T0>::invoke(boost::detail::function::function_buffer&, T0) [with FunctionObj = boost::arg<1>; R = void; T0 = const boost::shared_ptr<const sensor_msgs::PointCloud2_<std::allocator<void> > >&]’:
        /usr/include/boost/function/function_template.hpp:934:38:   required from ‘void boost::function1<R, T1>::assign_to(Functor) [with Functor = boost::arg<1>; R = void; T0 = const boost::shared_ptr<const sensor_msgs::PointCloud2_<std::allocator<void> > >&]’
        /usr/include/boost/function/function_template.hpp:722:7:   required from ‘boost::function1<R, T1>::function1(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = boost::arg<1>; R = void; T0 = const boost::shared_ptr<const sensor_msgs::PointCloud2_<std::allocator<void> > >&; typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
        /usr/include/boost/function/function_template.hpp:1069:16:   required from ‘boost::function<R(T0)>::function(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = boost::arg<1>; R = void; T0 = const boost::shared_ptr<const sensor_msgs::PointCloud2_<std::allocator<void> > >&; typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
        /opt/ros/indigo/include/message_filters/simple_filter.h:75:85:   required from ‘message_filters::Connection message_filters::SimpleFilter<M>::registerCallback(const C&) [with C = boost::arg<1>; M = sensor_msgs::PointCloud2_<std::allocator<void> >]
/home/anindya/catkin_ws/src/spin_hokuyo/src/sensor_task.cpp:89:66:   required from here
/usr/include/boost/function/function_template.hpp:153:11: error: no match for call to ‘(boost::arg<1>) (const boost::shared_ptr<const sensor_msgs::PointCloud2_<std::allocator<void> > >&)
           BOOST_FUNCTION_RETURN((*f)(BOOST_FUNCTION_ARGS));
           ^
make[2]: *** [spin_hokuyo/CMakeFiles/sensor_task.dir/src/sensor_task.cpp.o] Error 1
make[1]: *** [spin_hokuyo/CMakeFiles/sensor_task.dir/all] Error 2
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
anindya@anindya-Latitude-E7270:~/catkin_ws$