actionlib callback based SimpleActionClient bind error
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<mymessage> 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 ...
Can you post more of your actual code (and errors) rather than just snippets? I suspect something you've cut would be helpful...
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...
I asked because I think you have transcription errors. For instance, in
doneCb
, 2nd parameter isconst MyMessageConstPtr &result
, but I think it needs to beconst MyMessageResultConstPtr &result
. Actual code is helpful; simplified code (often) is not.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 aMyNamespace::MyClass&
.