Want to pass a string or int to a class callback.
Update Variation
n.subscribe <control_msgs::JointControllerState> ("/rrbot/joint2_position_controller/state", 10, boost::bind(&PublishOdometry::jointStateCallback2,this,_1,1),this);
ERR:/home/rnunziata/catkin_ws/src/gazebo_ros_demos/rrbot_control/src/robot_jntcmd_to_jntst.cpp: In constructor ‘PublishOdometry::PublishOdometry()’:
/home/rnunziata/catkin_ws/src/gazebo_ros_demos/rrbot_control/src/robot_jntcmd_to_jntst.cpp:29:185: error: no matching function for call to ‘ros::NodeHandle::subscribe(const char [40], int, boost::_bi::bind_t<void, boost::_mfi::mf2<void, PublishOdometry, control_msgs::JointControllerState_<std::allocator<void> >, int>, boost::_bi::list3<boost::_bi::value<PublishOdometry*>, boost::arg<1>, boost::_bi::value<int> > >, PublishOdometry* const)’
/home/rnunziata/catkin_ws/src/gazebo_ros_demos/rrbot_control/src/robot_jntcmd_to_jntst.cpp:29:185: note: candidates are:
/opt/ros/hydro/include/ros/node_handle.h:379:14: note: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(M), T*, const ros::TransportHints&)
/opt/ros/hydro/include/ros/node_handle.h:390:14: note: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(M)const, T*, const ros::TransportHints&)
/opt/ros/hydro/include/ros/node_handle.h:438:14: note: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(const boost::shared_ptr<const MReq>&), T*, const ros::TransportHints&)
/opt/ros/hydro/include/ros/node_handle.h:448:14: note: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(const boost::shared_ptr<const MReq>&)const, T*, const ros::TransportHints&)
/opt/ros/hydro/include/ros/node_handle.h:498:14: note: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(M), const boost::shared_ptr<U>&, const ros::TransportHints&)
/opt/ros/hydro/include/ros/node_handle.h:509:14: note: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(M)const, const boost::shared_ptr<U>&, const ros::TransportHints&)
/opt/ros/hydro/include/ros/node_handle.h:559:14: note: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(const boost::shared_ptr<const MReq>&), const boost::shared_ptr<U>&, const ros::TransportHints&)
/opt/ros/hydro/include/ros/node_handle.h:570:14: note: template<class M, class T> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (T::*)(const boost::shared_ptr<const MReq>&)const, const boost::shared_ptr<U>&, const ros::TransportHints&)
/opt/ros/hydro/include/ros/node_handle.h:618:14: note: template<class M> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (*)(M), const ros::TransportHints&)
/opt/ros/hydro/include/ros/node_handle.h:663:14: note: template<class M> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, void (*)(const boost::shared_ptr<const M>&), const ros::TransportHints&)
/opt/ros/hydro/include/ros/node_handle.h:706:14: note: template<class M> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, const boost::function<void(const boost::shared_ptr<const M>&)>&, const VoidConstPtr&, const ros::TransportHints&)
/opt/ros/hydro/include/ros/node_handle.h:752:14: note: template<class M, class C> ros::Subscriber ros::NodeHandle::subscribe(const string&, uint32_t, const boost::function<void(C)>&, const VoidConstPtr&, const ros::TransportHints&)
make[2]: *** [gazebo_ros_demos/rrbot_control/CMakeFiles/robot_jntcmd_to_jntst.dir/src/robot_jntcmd_to_jntst.cpp.o] Error 1
make[1]: *** [gazebo_ros_demos/rrbot_control/CMakeFiles/robot_jntcmd_to_jntst.dir/all] Error 2
make: *** [all] Error 2
=============================================================
Want to pass a string or int to a class callback. This code does not work...will not compile.
n.subscribe <control_msgs::JointControllerState>
("/rrbot/joint2_position_controller/state", 10,
boost::bind(&PublishOdometry::jointStateCallback2,this,_1,1));
void jointStateCallback2(const control_msgs::JointControllerState msg, const int)
ERR:
from /home/rnunziata/catkin_ws/src/gazebo_ros_demos/rrbot_control/src/robot_jntcmd_to_jntst.cpp:2:
/usr/include/boost/bind/bind.hpp: In member function ‘void boost::_bi::list3<A1, A2, A3>::operator()(boost::_bi::type<void>, F&, A&, int) [with F = boost::_mfi::mf2<void, PublishOdometry, control_msgs::JointControllerState_<std::allocator<void> >, int>, A = boost::_bi::list1<const boost::shared_ptr<const control_msgs::JointControllerState_<std::allocator<void> > >&>, A1 = boost::_bi::value<PublishOdometry*>, A2 = boost::arg<1>, A3 = boost::_bi::value<int>]’:
/usr/include/boost/bind/bind_template.hpp:47:59: instantiated 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 control_msgs::JointControllerState_<std::allocator<void> > >, R = void, F = boost::_mfi::mf2<void, PublishOdometry, control_msgs::JointControllerState_<std::allocator<void> >, int>, L = boost::_bi::list3<boost::_bi::value<PublishOdometry*>, boost::arg<1>, boost::_bi::value<int> >, boost::_bi::bind_t<R, F, L>::result_type = void]’
/usr/include/boost/function/function_template.hpp:153:11: instantiated 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, boost::_mfi::mf2<void, PublishOdometry, control_msgs::JointControllerState_<std::allocator<void> >, int>, boost::_bi::list3<boost::_bi::value<PublishOdometry*>, boost::arg<1>, boost::_bi::value<int> > >, R = void, T0 = const boost::shared_ptr<const control_msgs::JointControllerState_<std::allocator<void> > >&]’
/usr/include/boost/function/function_template.hpp:913:60: instantiated from ‘void boost::function1<R, T1>::assign_to(Functor) [with Functor = boost::_bi::bind_t<void, boost::_mfi::mf2<void, PublishOdometry, control_msgs::JointControllerState_<std::allocator<void> >, int>, boost::_bi::list3<boost::_bi::value<PublishOdometry*>, boost::arg<1>, boost::_bi::value<int> > >, R = void, T0 = const boost::shared_ptr<const control_msgs::JointControllerState_<std::allocator<void> > >&]’
/usr/include/boost/function/function_template.hpp:722:7: instantiated 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::_bi::bind_t<void, boost::_mfi::mf2<void, PublishOdometry, control_msgs::JointControllerState_<std::allocator<void> >, int>, boost::_bi::list3<boost::_bi::value<PublishOdometry*>, boost::arg<1>, boost::_bi::value<int> > >, R = void, T0 = const boost::shared_ptr<const control_msgs::JointControllerState_<std::allocator<void> > >&, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
/usr/include/boost/function/function_template.hpp:1064:16: instantiated from ‘boost::function<R(T0)>::function(Functor, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type) [with Functor = boost::_bi::bind_t<void, boost::_mfi::mf2<void, PublishOdometry, control_msgs::JointControllerState_<std::allocator<void> >, int>, boost::_bi::list3<boost::_bi::value<PublishOdometry*>, boost::arg<1>, boost::_bi::value<int> > >, R = void, T0 = const boost::shared_ptr<const control_msgs::JointControllerState_<std::allocator<void> > >&, typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
/home/rnunziata/catkin_ws/src/gazebo_ros_demos/rrbot_control/src/robot_jntcmd_to_jntst.cpp:27:72: instantiated from here
/usr/include/boost/bind/bind.hpp:392:9: error: no match for call to ‘(boost::_mfi::mf2<void, PublishOdometry, control_msgs::JointControllerState_<std::allocator<void> >, int>) (PublishOdometry*&, const boost::shared_ptr<const control_msgs::JointControllerState_<std::allocator<void> > >&, int&)’
/usr/include/boost/bind/mem_fn_template.hpp:253:75: note: candidates are:
/usr/include/boost/bind/mem_fn_template.hpp:278:7: note: R boost::_mfi::mf2<R, T, A1, A2>::operator()(T*, A1, A2) const [with R = void, T = PublishOdometry, A1 = control_msgs::JointControllerState_<std::allocator<void> >, A2 = int]
/usr/include/boost/bind/mem_fn_template.hpp:278:7: note: no known conversion for argument 2 from ‘const boost::shared_ptr<const control_msgs::JointControllerState_<std::allocator<void> > >’ to ‘control_msgs::JointControllerState_<std::allocator<void> >’
/usr/include/boost/bind/mem_fn_template.hpp:283:25: note: template<class U> R boost::_mfi::mf2::operator()(U&, A1, A2) const [with U = U, R = void, T = PublishOdometry, A1 = control_msgs::JointControllerState_<std::allocator<void> >, A2 = int]
/usr/include/boost/bind/mem_fn_template.hpp:291:25: note: template<class U> R boost::_mfi::mf2::operator()(const U&, A1, A2) const [with U = U, R = void, T = PublishOdometry, A1 = control_msgs::JointControllerState_<std::allocator<void> >, A2 = int]
/usr/include/boost/bind/mem_fn_template.hpp:299:7: note: R boost::_mfi::mf2<R, T, A1, A2>::operator()(T&, A1, A2) const [with R = void, T = PublishOdometry, A1 = control_msgs::JointControllerState_<std::allocator<void> >, A2 = int]
/usr/include/boost/bind/mem_fn_template.hpp:299:7: note: no known conversion for argument 1 from ‘PublishOdometry*’ to ‘PublishOdometry&’
make[2]: *** [gazebo_ros_demos/rrbot_control/CMakeFiles/robot_jntcmd_to_jntst.dir/src/robot_jntcmd_to_jntst.cpp.o] Error 1
make[1]: *** [gazebo_ros_demos/rrbot_control/CMakeFiles/robot_jntcmd_to_jntst.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed
Asked by rnunziata on 2013-08-22 16:24:54 UTC
Answers
Try adding the message specification
If that doesn't work, copy the actual error here.
Asked by dornhege on 2013-08-22 23:47:09 UTC
Comments
can not format in comment section I updated main question.
Asked by rnunziata on 2013-08-23 03:25:37 UTC
Which one is your callback function? jointStateCallback2 or jointStateCallback ?
Asked by Joao Ferreira Jr on 2013-08-23 05:56:36 UTC
Sorry bad cut and paste ...updated main questiong
Asked by rnunziata on 2013-08-23 06:07:34 UTC
I didn't test it yet, but try replacing your subscription to this:
n.subscribe
Asked by Joao Ferreira Jr on 2013-08-23 06:23:08 UTC
Comments
Tried it...updated question...does not resolve
Asked by rnunziata on 2013-08-23 06:39:29 UTC
Ok... I don't have any better idea. I guessed it could work because I had to do that when tried to subscribe to a topic inside an actionServer...
it worked like that:
ros::NodeHandle nh; ros::Subscriber hand_detect_sub = nh.subscribe("highlighted_user" , 5 , &ActivityServer::handDetectionCallback , this);
In that case, I was already inside my callback function - called ActivityServer::executeCB - when I subscribed to ActivityServer::handDetectionCallback
Asked by Joao Ferreira Jr on 2013-08-23 06:49:17 UTC
Comments