Hi folks,
so today I decided to write a callback based SimpleActionClient to get notified whenever a goal has finished. I found this tutorial, but following the instructions will still give me errors. Please note: Using the SimpleActionClient the "normal" way works fine for me, but I need to change it to be callback based.
So basically, I have a class MyNamespace::MyClass
. Then, when I want to send a goal, I use
client.sendGoal(goal, boost::bind(&MyNamespace::MyClass::doneCb, this, _1, _2));
With the doneCb
class defined like in the tutorial:
void doneCb(const actionlib::SimpleClientGoalState& state, const MyMessageActionResultConstPtr &result);
The error occurs at the line there I send the goal, it says, the template argument deduction/substitution failed.
Here some excerpt of the infinite error messages I get:
included from ...required from...stuff...
/usr/include/boost/bind/bind.hpp:392: error: no match for call to '(boost::_mfi::mf2<void, MyNamespace::MyClass, const actionlib::SimpleClientGoalState&, const boost::shared_ptr<const MyMessageActionResult_<std::allocator<void> > >&>) (MyNamespace::MyClass*&, const actionlib::SimpleClientGoalState&, const boost::shared_ptr<const MyMessageResult_<std::allocator<void> > >&)'
unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]);
^
included from ... required from... stuff...
/usr/include/boost/bind/mem_fn_template.hpp:299: note: no known conversion for argument 1 from 'MyNamespace::MyClass*' to 'MyNamespace::MyClass&'
I don't get what I did wrong, as I followed the example and tried multiple different cases of including and excluding the activeCb and feedbackCb, it all ends in similar errors.
Thank you for your support,
Marcel
Edit: more code and full error message:
More Code:
namespace(MyNamespace) {
class MyClass {
public:
MyClass () : client("action_name", true) { ... }
....
functionThatSendsGoal() {
MyMessageGoal goal;
// fill goal message, do stuff unrelated to client
client.sendGoal(goal, boost::bind(&MyNamespace::MyClass::doneCb, this, _1, _2)); //compile error occurs here return; } doneCb(const actionlib::SimpleClientGoalState& state, const MyMessageActionResultConstPtr &result) { //do stuff return; } protected: actionlib::SimpleActionClient client; ... };
MyMessage is actually a control_msgs::FollowJointTrajectory
message.
Full Error Message, for those who can actually understand it:
In file included from /usr/include/boost/bind.hpp:22:0,
from /opt/ros/indigo/include/ros/publisher.h:35,
from /opt/ros/indigo/include/ros/node_handle.h:32,
from /opt/ros/indigo/include/ros/ros.h:45,
from /home/marcel/ros/catkin_ws/src/project/src/MyNode.h:5,
from /home/marcel/ros/catkin_ws/src/project/src/MyNode.cpp:1:
/usr/include/boost/bind/bind.hpp: In instantiation of ‘void boost::_bi::list3<A1, A2, A3>::operator()(boost::_bi::type<void>, F&, A&, int) [with F = boost::_mfi::mf2<void, MyNamespace::MyNode, const actionlib::SimpleClientGoalState&, const boost::shared_ptr<const control_msgs::FollowJointTrajectoryActionResult_<std::allocator<void> > >&>; A = boost::_bi::list2<const actionlib::SimpleClientGoalState&, const boost::shared_ptr<const control_msgs::FollowJointTrajectoryResult_<std::allocator<void> > >&>; A1 = boost::_bi::value<MyNamespace::MyClass*>; A2 = boost::arg<1>; A3 = boost::arg<2>]’:
/usr/include/boost/bind/bind_template.hpp:102:59: required from ‘boost::_bi::bind_t<R, F, L>::result_type boost::_bi::bind_t<R, F, L>::operator()(const A1&, const A2&) [with A1 = actionlib::SimpleClientGoalState; A2 = boost::shared_ptr<const control_msgs::FollowJointTrajectoryResult_<std::allocator<void> > >; R = void; F = boost::_mfi::mf2<void, MyNamespace::MyClass, const actionlib::SimpleClientGoalState&, const boost::shared_ptr<const control_msgs::FollowJointTrajectoryActionResult_<std::allocator<void> > >&>; L = boost::_bi::list3<boost::_bi::value<MyNamespace::MyClass*>, boost::arg<1>, boost::arg<2> >; boost::_bi::bind_t<R, F, L>::result_type = void]’
/usr/include/boost/function/function_template.hpp:153:11: required from ‘static void boost::detail::function::void_function_obj_invoker2<FunctionObj, R, T0, T1>::invoke(boost::detail::function::function_buffer&, T0, T1) [with FunctionObj = boost::_bi::bind_t<void, boost::_mfi::mf2<void, MyNamespace::MyClass, const actionlib::SimpleClientGoalState&, const boost::shared_ptr<const control_msgs::FollowJointTrajectoryActionResult_<std::allocator<void> > >&>, boost::_bi::list3<boost::_bi::value<MyNamespace::MyClass*>, boost::arg<1>, boost::arg<2> > >; R = void; T0 = const actionlib::SimpleClientGoalState&; T1 = const boost::shared_ptr<const control_msgs::FollowJointTrajectoryResult_<std::allocator<void> > >&]’
/usr/include/boost/function/function_template.hpp:934:38: required from ‘void boost::function2<R, T1, T2>::assign_to(Functor) [with Functor = boost::_bi::bind_t<void, boost::_mfi::mf2<void, MyNamespace::MyClass, const actionlib::SimpleClientGoalState&, const boost::shared_ptr<const control_msgs::FollowJointTrajectoryActionResult_<std::allocator<void> > >&>, boost::_bi::list3<boost::_bi::value<MyNamespace::MyClass*>, boost::arg<1>, boost::arg<2> > >; R = void; T0 = const actionlib::SimpleClientGoalState&; T1 = const boost::shared_ptr<const control_msgs::FollowJointTrajectoryResult_<std::allocator<void> > >&]’
/usr/include/boost/function/function_template.hpp:722:7: required from ‘boost::function2<R, T1, T2>::function2(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, MyNamespace::MyClass, const actionlib::SimpleClientGoalState&, const boost::shared_ptr<const control_msgs::FollowJointTrajectoryActionResult_<std::allocator<void> > >&>, boost::_bi::list3<boost::_bi::value<MyNamespace::MyClass*>, boost::arg<1>, boost::arg<2> > >; R = void; T0 = const actionlib::SimpleClientGoalState&; T1 = const boost::shared_ptr<const control_msgs::FollowJointTrajectoryResult_<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:1069:16: required from ‘boost::function<R(T0, T1)>::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, MyNamespace::MyClass, const actionlib::SimpleClientGoalState&, const boost::shared_ptr<const control_msgs::FollowJointTrajectoryActionResult_<std::allocator<void> > >&>, boost::_bi::list3<boost::_bi::value<MyNamespace::MyClass*>, boost::arg<1>, boost::arg<2> > >; R = void; T0 = const actionlib::SimpleClientGoalState&; T1 = const boost::shared_ptr<const control_msgs::FollowJointTrajectoryResult_<std::allocator<void> > >&; typename boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value, int>::type = int]’
/home/marcel/ros/catkin_ws/src/project/src/MyNode.cpp:374:140: required from here
/usr/include/boost/bind/bind.hpp:392:34: error: no match for call to ‘(boost::_mfi::mf2<void, MyNamespace::MyClass, const actionlib::SimpleClientGoalState&, const boost::shared_ptr<const control_msgs::FollowJointTrajectoryActionResult_<std::allocator<void> > >&>) (MyNamespace::MyClass*&, const actionlib::SimpleClientGoalState&, const boost::shared_ptr<const control_msgs::FollowJointTrajectoryResult_<std::allocator<void> > >&)’
unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]);
^
In file included from /usr/include/boost/mem_fn.hpp:22:0,
from /usr/include/boost/function/detail/prologue.hpp:18,
from /usr/include/boost/function.hpp:24,
from /opt/ros/indigo/include/ros/forwards.h:39,
from /opt/ros/indigo/include/ros/common.h:37,
from /opt/ros/indigo/include/ros/ros.h:43,
from /home/marcel/ros/catkin_ws/src/projcet/src/MyNode.h:5,
from /home/marcel/ros/catkin_ws/src/project/src/MyNode.cpp:1:
/usr/include/boost/bind/mem_fn_template.hpp:253:75: note: candidates are:
template<class R, class T, class A1, class A2 BOOST_MEM_FN_CLASS_F> class BOOST_MEM_FN_NAME(mf2)
^
In file included from /usr/include/boost/bind/mem_fn.hpp:215:0,
from /usr/include/boost/mem_fn.hpp:22,
from /usr/include/boost/function/detail/prologue.hpp:18,
from /usr/include/boost/function.hpp:24,
from /opt/ros/indigo/include/ros/forwards.h:39,
from /opt/ros/indigo/include/ros/common.h:37,
from /opt/ros/indigo/include/ros/ros.h:43,
from /home/marcel/ros/project/src/MyNode.h:5,
from /home/marcel/ros/project/src/MyNode.cpp:1:
/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 = MyNamespace::MyClass; A1 = const actionlib::SimpleClientGoalState&; A2 = const boost::shared_ptr<const control_msgs::FollowJointTrajectoryActionResult_<std::allocator<void> > >&]
R operator()(T * p, A1 a1, A2 a2) const
^
/usr/include/boost/bind/mem_fn_template.hpp:278:7: note: no known conversion for argument 3 from ‘const boost::shared_ptr<const control_msgs::FollowJointTrajectoryResult_<std::allocator<void> > >’ to ‘const boost::shared_ptr<const control_msgs::FollowJointTrajectoryActionResult_<std::allocator<void> > >&’
/usr/include/boost/bind/mem_fn_template.hpp:283:25: note: template<class U> R boost::_mfi::mf2<R, T, A1, A2>::operator()(U&, A1, A2) const [with U = U; R = void; T = MyNamespace::MyClass; A1 = const actionlib::SimpleClientGoalState&; A2 = const boost::shared_ptr<const control_msgs::FollowJointTrajectoryActionResult_<std::allocator<void> > >&]
template<class U> R operator()(U & u, A1 a1, A2 a2) const
^
/usr/include/boost/bind/mem_fn_template.hpp:283:25: note: template argument deduction/substitution failed:
In file included from /usr/include/boost/bind.hpp:22:0,
from /opt/ros/indigo/include/ros/publisher.h:35,
from /opt/ros/indigo/include/ros/node_handle.h:32,
from /opt/ros/indigo/include/ros/ros.h:45,
from /home/marcel/ros/project/src/MyNode.h:5,
from /home/marcel/ros/project/src/MyNode.cpp:1:
/usr/include/boost/bind/bind.hpp:392:34: note: cannot convert ‘(& a)->boost::_bi::list2<A1, A2>::operator[]<const actionlib::SimpleClientGoalState&, const boost::shared_ptr<const control_msgs::FollowJointTrajectoryResult_<std::allocator<void> > >&>(boost::_bi::storage3<A1, A2, boost::arg<I> >::a3_<boost::_bi::value<MyNamespace::MyClass*>, boost::arg<1>, 2>)’ (type ‘const boost::shared_ptr<const control_msgs::FollowJointTrajectoryResult_<std::allocator<void> > >’) to type ‘const boost::shared_ptr<const control_msgs::FollowJointTrajectoryActionResult_<std::allocator<void> > >&’
unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]);
^
In file included from /usr/include/boost/bind/mem_fn.hpp:215:0,
from /usr/include/boost/mem_fn.hpp:22,
from /usr/include/boost/function/detail/prologue.hpp:18,
from /usr/include/boost/function.hpp:24,
from /opt/ros/indigo/include/ros/forwards.h:39,
from /opt/ros/indigo/include/ros/common.h:37,
from /opt/ros/indigo/include/ros/ros.h:43,
from /home/marcel/ros/project/src/MyNode.h:5,
from /home/marcel/ros/project/src/MyNode.cpp:1:
/usr/include/boost/bind/mem_fn_template.hpp:291:25: note: template<class U> R boost::_mfi::mf2<R, T, A1, A2>::operator()(const U&, A1, A2) const [with U = U; R = void; T = MyNamespace::MyClass; A1 = const actionlib::SimpleClientGoalState&; A2 = const boost::shared_ptr<const control_msgs::FollowJointTrajectoryActionResult_<std::allocator<void> > >&]
template<class U> R operator()(U const & u, A1 a1, A2 a2) const
^
/usr/include/boost/bind/mem_fn_template.hpp:291:25: note: template argument deduction/substitution failed:
In file included from /usr/include/boost/bind.hpp:22:0,
from /opt/ros/indigo/include/ros/publisher.h:35,
from /opt/ros/indigo/include/ros/node_handle.h:32,
from /opt/ros/indigo/include/ros/ros.h:45,
from /home/marcel/ros/project/src/MyNode.h:5,
from /home/marcel/ros/project/src/MyNode.cpp:1:
/usr/include/boost/bind/bind.hpp:392:34: note: cannot convert ‘(& a)->boost::_bi::list2<A1, A2>::operator[]<const actionlib::SimpleClientGoalState&, const boost::shared_ptr<const control_msgs::FollowJointTrajectoryResult_<std::allocator<void> > >&>(boost::_bi::storage3<A1, A2, boost::arg<I> >::a3_<boost::_bi::value<MyNamespace::MyClass*>, boost::arg<1>, 2>)’ (type ‘const boost::shared_ptr<const control_msgs::FollowJointTrajectoryResult_<std::allocator<void> > >’) to type ‘const boost::shared_ptr<const control_msgs::FollowJointTrajectoryActionResult_<std::allocator<void> > >&’
unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_], a[base_type::a3_]);
^
In file included from /usr/include/boost/bind/mem_fn.hpp:215:0,
from /usr/include/boost/mem_fn.hpp:22,
from /usr/include/boost/function/detail/prologue.hpp:18,
from /usr/include/boost/function.hpp:24,
from /opt/ros/indigo/include/ros/forwards.h:39,
from /opt/ros/indigo/include/ros/common.h:37,
from /opt/ros/indigo/include/ros/ros.h:43,
from /home/marcel/ros/project/src/MyNode.h:5,
from /home/marcel/ros/project/src/MyNode.cpp:1:
/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 = MyNamespace::MyClass; A1 = const actionlib::SimpleClientGoalState&; A2 = const boost::shared_ptr<const control_msgs::FollowJointTrajectoryActionResult_<std::allocator<void> > >&]
R operator()(T & t, A1 a1, A2 a2) const
^
/usr/include/boost/bind/mem_fn_template.hpp:299:7: note: no known conversion for argument 1 from ‘MyNamespace::MyClass*’ to ‘MyNamespace::MyClass&’
make[2]: *** [project/CMakeFiles/project.dir/src/MyNode.o] Fehler 1
make[1]: *** [project/CMakeFiles/project.dir/all] Fehler 2
make: *** [all] Fehler 2
Originally posted by Marcel Usai on ROS Answers with karma: 200 on 2014-10-23
Post score: 1
Original comments
Comment by kramer on 2014-10-23:
Can you post more of your actual code (and errors) rather than just snippets? I suspect something you've cut would be helpful...
Comment by Marcel Usai on 2014-10-27:
Hi kramer, I updated my post and added some more code and the full error message.I do not think, that more code would help, as it all happens at the line where I try to send my goal. But maybe someone can say what exactly is wrong by understanding these error messages...
Comment by kramer on 2014-10-27:
I asked because I think you have transcription errors. For instance, in doneCb
, 2nd parameter is const MyMessageConstPtr &result
, but I think it needs to be const MyMessageResultConstPtr &result
. Actual code is helpful; simplified code (often) is not.
Comment by kramer on 2014-10-27:
As I'm sure you realize, the original (piece of the) error message you posted is helpful and where I'd start -- you're attempting to use a MyNamespace::MyClass*
where it should be a MyNamespace::MyClass&
.