ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

actionlib callback based SimpleActionClient bind error

asked 2014-10-23 07:03:41 -0500

Marcel Usai gravatar image

updated 2014-10-28 04:42:53 -0500

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,


Edit: more code and full error message:

More Code:

namespace(MyNamespace) {
class MyClass {
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 ...
edit retag flag offensive close merge delete


Can you post more of your actual code (and errors) rather than just snippets? I suspect something you've cut would be helpful...

kramer gravatar image kramer  ( 2014-10-23 17:36:13 -0500 )edit

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...

Marcel Usai gravatar image Marcel Usai  ( 2014-10-27 03:00:35 -0500 )edit

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.

kramer gravatar image kramer  ( 2014-10-27 09:33:34 -0500 )edit

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&.

kramer gravatar image kramer  ( 2014-10-27 09:37:08 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2014-10-28 04:45:30 -0500

Marcel Usai gravatar image

updated 2014-10-28 04:46:20 -0500

Thanks to your comment, I figured it out:

I was using a

const MyMessageActionResultConstPtr &result

instead of

const MyMessageResultConstPtr &result

This at least got me rid of the previous compile error.

edit flag offensive delete link more


Well, that's...unexpected. But I'm glad to have helped.

kramer gravatar image kramer  ( 2014-10-28 07:55:30 -0500 )edit

Question Tools



Asked: 2014-10-23 07:03:41 -0500

Seen: 2,245 times

Last updated: Oct 28 '14