Ask Your Question
0

About using callbacks [Not solved]

asked 2015-02-10 02:18:05 -0500

pexison gravatar image

updated 2015-02-10 06:45:27 -0500

Hello, I made the actionlib tutorial and I was trying to make my own a simple action handler, but there is an error when I use catkin_make:

/usr/include/boost/bind/mem_fn_template.hpp:184:7: note:   no known conversion for argument 1 from ‘ControlAction*’ to ‘ControlAction&’
make[2]: *** [control/CMakeFiles/control_server.dir/src/control_server.cpp.o] Error 1
make[1]: *** [control/CMakeFiles/control_server.dir/all] Error 2
make: *** [all] Error 2

The code of the action handler is:

#include <ros/ros.h>
#include <geometry_msgs/Twist.h>
#include <actionlib/server/simple_action_server.h>
#include <control/ControlAction.h>

class ControlAction {
  protected:
    ros::NodeHandle nh_;
    actionlib::SimpleActionServer<control::ControlAction> as_;
    std::string action_name_;

  public:
    ControlAction(std::string name):
    as_(nh_, name, boost::bind(&ControlAction::executeCB, this, _1), false),
    action_name_(name)
    {
      as_.start();
    }

   ~ControlAction(void)
   {
   }

   void executeCB(const control::ControlGoal &goal) {
   }
};

int main(int argc, char** argv) {
  ros::init(argc, argv, "control");
  ControlAction control(ros::this_node::getName());
  ros::spin();

  return 0;
}

And i am using the geometry_msgs/Twist as data type in the .action file. I am looking forward to use this callback to move the turtlebot, how can i use the cmd_vel here? (if this were a publisher node_pub.publisher(goal) will be the answer, but there must be another way)

The compilation problem was solved, but stills remaining the other part of the question related about how to use cmd_vel Thanks beforehand!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
3

answered 2015-02-10 03:07:01 -0500

dornhege gravatar image

I think your callback signature is wrong. It wants a pointer, not a reference, so just add add Ptr to the data type.

edit flag offensive delete link more

Comments

I changed it to void executeCB(const control::ControlGoalPtr &goal) but still getting

/usr/include/boost/bind/mem_fn_template.hpp:184:7: note:   no known conversion for argument 1 from ‘ControlAction*’ to ‘ControlAction&’
pexison gravatar imagepexison ( 2015-02-10 04:09:16 -0500 )edit
1

void executeCB(const control::ControlGoalConstPtr &goal) adding Const and Ptr to the signature of the callback solved the problem!

pexison gravatar imagepexison ( 2015-02-10 05:03:13 -0500 )edit

@pexison please accept the answer using the checkbox at the left so it's known to be solved.

tfoote gravatar imagetfoote ( 2015-02-11 20:46:16 -0500 )edit

this was only one part of the question, it remains:

The compilation problem was solved, but stills remaining the other part of the question related about how to use cmd_vel as a callback

pexison gravatar imagepexison ( 2015-02-12 02:47:17 -0500 )edit

It is as you said in the question: You need a publisher to a topic like /cmd_vel that continuously publishes the Twist the robot should execute. There usually is no other way as that is what the robot interface provides.

dornhege gravatar imagedornhege ( 2015-02-12 03:11:22 -0500 )edit

Hello @dornhege, I am facing similar compilation issue, but I used pointer only. Still it is there. Can you please have a look on it: https://answers.ros.org/question/2940...

saurabh gravatar imagesaurabh ( 2018-06-14 01:46:23 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-02-10 02:18:05 -0500

Seen: 298 times

Last updated: Feb 10 '15