Message Filters Time Sequencer not compiling - Roscpp
I'm trying to utilize the ROS Indigo message_filters::TimeSequencer
library to delay messages coming in from a certain topic and republishing them onto a new topic. However, my code does not compile and I get the following error: https://pastebin.com/iUavjXR2 which states that I have mismatched types for my callback.
EDIT: I have compiled this on kinetic and it seems to be working... I am trying to find out why though and will update this when I find an answer.
Below is my code
#include <ros/ros.h>
#include <geometry_msgs/TwistStamped.h>
#include <message_filters/time_sequencer.h>
#include <message_filters/subscriber.h>
using namespace geometry_msgs;
using namespace message_filters;
ros::Publisher pub;
void delay_cb(const TwistStampedConstPtr& delay_vel)
{
TwistStamped new_vel;
new_vel.header.stamp = ros::Time::now();
new_vel.twist.angular.z = delay_vel->twist.angular.z;
new_vel.twist.linear.x = delay_vel->twist.linear.x;
pub.publish(new_vel);
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "delay_node");
ros::NodeHandle n;
double delay_time = 1.0;
std::string delay_topic = "/jackal_bsc/key_vel_stamped";
std::string new_topic = "/jackal_bsc/key_vel_delay";
n.param<std::string>("/jackal_bsc/delay_topic", delay_topic, "/jackal_bsc/key_vel_stamped");
n.param<std::string>("/jackal_bsc/new_topic", new_topic, "/jackal_bsc/key_vel_delay");
n.param("/jackal_bsc/delay_time", delay_time, 1.0);
pub = n.advertise<TwistStamped>(new_topic, 10);
message_filters::Subscriber<TwistStamped> sub(n, delay_topic, 1);
message_filters::TimeSequencer<TwistStamped> seq(sub, ros::Duration(0.1),
ros::Duration(0.01), 10);
seq.registerCallback(delay_cb);
ros::spin();
return 0;
}
I'm using a constant pointer in my callback, and I've followed the ROS tutorials for message_filters
to the T. What could be my issue?
Thanks!
Edit: I put the error in the pastebin link but at gvdhoorn's request, ill put it here:
In file included from /opt/ros/indigo/include/message_filters/time_sequencer.h:41:0,
from /home/piraka9011/catkin_ws/src/jackal_bsc/src/delay_node.cpp:4:
/opt/ros/indigo/include/message_filters/simple_filter.h: In instantiation of ‘message_filters::Connection message_filters::SimpleFilter<M>::registerCallback(void (*)(P)) [with P = const boost::shared_ptr<const geometry_msgs::TwistStamped_<std::allocator<void> > >&; M = geometry_msgs::TwistStamped_<std::allocator<void> >]’:
/home/piraka9011/catkin_ws/src/jackal_bsc/src/delay_node.cpp:34:34: required from here
/opt/ros/indigo/include/message_filters/simple_filter.h:96:99: error: no matching function for call to ‘message_filters::Signal1<geometry_msgs::TwistStamped_<std::allocator<void> > >::addCallback(void (*&)(const boost::shared_ptr<const geometry_msgs::TwistStamped_<std::allocator<void> > >&))’
return Connection(boost::bind(&Signal::removeCallback, &signal_, signal_.addCallback(callback)));
^
/opt/ros/indigo/include/message_filters/simple_filter.h:96:99: note: candidate is:
In file included from /opt/ros/indigo/include/message_filters/simple_filter.h:41:0,
from /opt/ros/indigo/include/message_filters/time_sequencer.h:41,
from /home/piraka9011/catkin_ws/src/jackal_bsc/src/delay_node.cpp:4:
/opt/ros/indigo/include/message_filters/signal1.h:91:22: note: template<class P> message_filters::Signal1<M>::CallbackHelper1Ptr message_filters::Signal1<M>::addCallback(const boost::function<void(P)>&) [with P = P; M = geometry_msgs::TwistStamped_<std::allocator<void> >]
CallbackHelper1Ptr addCallback(const boost::function<void(P)>& callback)
^
/opt/ros/indigo/include/message_filters/signal1.h:91:22: note: template argument deduction/substitution failed:
In file included from /opt/ros/indigo ...
Please include the error message in your post. There is no reason not to do that.