Ask Your Question
0

Message Filters Time Sequencer not compiling - Roscpp

asked 2018-02-22 09:32:53 -0600

piraka9011 gravatar image

updated 2018-03-09 20:02:21 -0600

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

Comments

1

Please include the error message in your post. There is no reason not to do that.

gvdhoorn gravatar imagegvdhoorn ( 2018-02-23 04:10:30 -0600 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2018-04-12 21:03:36 -0600

pan gravatar image

I have no experience using message_filters::TimeSequencer lib. But from your error: no matching function for call to .... we can infer that you made a mistake of using message_filters.... which is not decalied, please check the parameter type, whether it is consistent, espacially pay attention to distinguish boost and std lib. hope it will help you.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-02-22 09:32:53 -0600

Seen: 251 times

Last updated: Apr 12 '18