How to add parameters to a subscriber callback function given that it is also an action_client
Hello, I'm new to ROS and my situation is the following: I have a node which subscribes to a Topic, so of course I have my callback function (which by the way uses a custom message so the problem may be there, I don't know. I don't really know C++ either :D ). The point is that this node must also be a client for an actionlib Client-Server structure. So every time my node reads something from the topic it is subscribed to, I need also to inform my actionlib Server. This is why I need to have a "Client" parameter in my callback function, to send also a message to the Server.
My callback SHOULD look like this:
void polygonCallback(const es_1::Draw msg, Client* cl){//Stuff}
And I just defined "Client" like this
typedef actionlib::SimpleActionClient<es_1::polygonAction> Client;
Now, I found online that to do what I want to do I sould use boost::bind()
and I did. Just like this:
ros::Subscriber sub = n.subscribe<es_1::Draw>("draw", 1000, boost::bind(polygonCallback,_1,&client));
But when I try to "catkin_make" this is the error that pops out:
In file included from /usr/include/boost/bind.hpp:22:0,
from /opt/ros/kinetic/include/ros/publisher.h:35,
from /opt/ros/kinetic/include/ros/node_handle.h:32,
from /opt/ros/kinetic/include/ros/ros.h:45,
from /home/canniz/Desktop/catkin_ws/src/es_1/src/polygon_action_client.cpp:1:
/usr/include/boost/bind/bind.hpp: In instantiation of ‘void boost::_bi::list2<A1, A2>::operator()(boost::_bi::type<void>, F&, A&, int) [with F = void (*)(es_1::Draw_<std::allocator<void> >, actionlib::SimpleActionClient<es_1::polygonAction_<std::allocator<void> > >*); A = boost::_bi::list1<const boost::shared_ptr<const es_1::Draw_<std::allocator<void> > >&>; A1 = boost::arg<1>; A2 = boost::_bi::value<actionlib::SimpleActionClient<es_1::polygonAction_<std::allocator<void> > >*>]’:
/usr/include/boost/bind/bind_template.hpp:47:59: required from ‘boost::_bi::bind_t<R, F, L>::result_type boost::_bi::bind_t<R, F, L>::operator()(const A1&) [with A1 = boost::shared_ptr<const es_1::Draw_<std::allocator<void> > >; R = void; F = void (*)(es_1::Draw_<std::allocator<void> >, actionlib::SimpleActionClient<es_1::polygonAction_<std::allocator<void> > >*); L = boost::_bi::list2<boost::arg<1>, boost::_bi::value<actionlib::SimpleActionClient<es_1::polygonAction_<std::allocator<void> > >*> >; boost::_bi::bind_t<R, F, L>::result_type = void]’
/usr/include/boost/function/function_template.hpp:159:11: required from ‘static void boost::detail::function::void_function_obj_invoker1<FunctionObj, R, T0>::invoke(boost::detail::function::function_buffer&, T0) [with FunctionObj = boost::_bi::bind_t<void, void (*)(es_1::Draw_<std::allocator<void> >, actionlib::SimpleActionClient<es_1::polygonAction_<std::allocator<void> > >*), boost::_bi::list2<boost::arg<1>, boost::_bi::value<actionlib::SimpleActionClient<es_1::polygonAction_<std::allocator<void> > >*> > >; R = void; T0 = const boost::shared_ptr<const es_1::Draw_<std::allocator<void> > >&]’
/usr/include/boost/function/function_template.hpp:940:38: required from ‘void boost::function1<R, T1>::assign_to(Functor) [with Functor = boost::_bi::bind_t<void, void (*)(es_1::Draw_<std::allocator<void> >, actionlib::SimpleActionClient<es_1::polygonAction_<std::allocator<void> > >*), boost::_bi::list2<boost::arg<1>, boost::_bi::value<actionlib::SimpleActionClient<es_1::polygonAction_<std::allocator<void> > >*> > >; R = void; T0 = const boost::shared_ptr<const es_1::Draw_<std::allocator<void> > >&]’
/usr/include/boost/function/function_template.hpp:728:7: required ...