Problem with message_filters::cache
Hello,
i am trying to cache messages of a topic. Unfortunately i can't compile it.
I've read these examples yet:
http://www.ros.org/wiki/message_filters#Cache
http://mirror.umd.edu/roswiki/doc/unstable/api/message_filters/html/c++/
Thats a minimal example of my code:
#include "ros/ros.h"
#include "message_filters/subscriber.h"
#include "message_filters/cache.h"
#include "std_msgs/Int16.h"
void some_function (std_msgs::Int16 i)
{
std::cout << "i = " << i.data << std::endl;
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "caching_example");
ros::NodeHandle nh;
message_filters::Subscriber<std_msgs::Int16> sub(nh, "some_topic", 1);
message_filters::Cache<std_msgs::Int16> cache(sub, 100);
cache.registerCallback(some_function);
ros::spin();
}
The compiler output is:
blizzard@Blizzard-Kubuntu:~$ rosmake caching_example
[ rosmake ] rosmake starting...
[ rosmake ] Packages requested are: ['caching_example']
[ rosmake ] Logging to directory /home/blizzard/.ros/rosmake/rosmake_output-20120911-224838
[ rosmake ] Expanded args ['caching_example'] to:
['caching_example']
[rosmake-0] Starting >>> roslang [ make]
[rosmake-0] Finished <<< roslang No Makefile in package roslang
[rosmake-0] Starting >>> roscpp [ make ]
[rosmake-0] Finished <<< roscpp No Makefile in package roscpp
[rosmake-0] Starting >>> caching_example [ make ]
[ rosmake ] Last 40 linesching_example: 16.8 sec ]
Active 2/3 Complete ]
{-------------------------------------------------------------------------------
make[1]: Entering directory `/home/blizzard/ROS/caching_example/build'
make[2]: Entering directory `/home/blizzard/ROS/caching_example/build'
make[3]: Entering directory `/home/blizzard/ROS/caching_example/build'
make[3]: Leaving directory `/home/blizzard/ROS/caching_example/build'
[ 0%] Built target rospack_genmsg_libexe
make[3]: Entering directory `/home/blizzard/ROS/caching_example/build'
make[3]: Leaving directory `/home/blizzard/ROS/caching_example/build'
[ 0%] Built target rosbuild_precompile
make[3]: Entering directory `/home/blizzard/ROS/caching_example/build'
make[3]: Leaving directory `/home/blizzard/ROS/caching_example/build'
make[3]: Entering directory `/home/blizzard/ROS/caching_example/build'
[100%] Building CXX object CMakeFiles/someTest.dir/src/test.o
In file included from /opt/ros/fuerte/include/message_filters/subscriber.h:44:0,
from /home/blizzard/ROS/caching_example/src/test.cpp:2:
/opt/ros/fuerte/include/message_filters/simple_filter.h: In member function ‘message_filters::Connection message_filters::SimpleFilter<M>::registerCallback(void (*)(P)) [with P = std_msgs::Int16_<std::allocator<void> >, M = std_msgs::Int16_<std::allocator<void> >]’:
/home/blizzard/ROS/caching_example/src/test.cpp:19:41: instantiated from here
/opt/ros/fuerte/include/message_filters/simple_filter.h:96:100: error: no matching function for call to ‘message_filters::Signal1<std_msgs::Int16_<std::allocator<void> > >::addCallback(void (*&)(std_msgs::Int16_<std::allocator<void> >))’
/opt/ros/fuerte/include/message_filters/simple_filter.h:96:100: note: candidate is:
/opt/ros/fuerte/include/message_filters/signal1.h:91:22: note: template<class P> message_filters::Signal1<M>::CallbackHelper1Ptr message_filters::Signal1::addCallback(const boost::function<void(P)>&) [with P = P, M = std_msgs::Int16_<std::allocator<void> >, message_filters::Signal1<M>::CallbackHelper1Ptr = boost::shared_ptr<message_filters::CallbackHelper1<std_msgs::Int16_<std::allocator<void> > > >]
In file included from /home/blizzard/ROS/caching_example/src/test.cpp:3:0:
/opt/ros/fuerte/include/message_filters/cache.h: In member function ‘void message_filters::Cache<M>::add(const EventType&) [with M = std_msgs::Int16_<std::allocator<void> >, message_filters::Cache<M>::EventType = ros::MessageEvent<const std_msgs::Int16_<std::allocator<void> > >]’:
/opt/ros/fuerte/include/message_filters/cache.h:330:5: instantiated from ‘void message_filters::Cache<M>::callback(const EventType&) [with ...
It would help to see your compiler output.
There it is :)