errors while using cache filter in message_filters

asked 2018-02-20 12:39:14 -0500

Spartan_007 gravatar image

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 ...
(more)
edit retag flag offensive close merge delete

Comments

@Spartan_007 did you ever figure this out? I'm wondering if you need to use PointCloud2ConstPtr instead for your callback argument and then simply sensor_msgs::PointCloud2 still for the cache and subscriber.

ia gravatar image ia  ( 2021-03-19 11:38:32 -0500 )edit