Ask Your Question
0

compilation error in ros action server code

asked 2018-06-13 15:29:37 -0600

saurabh gravatar image

updated 2018-06-15 02:16:59 -0600

Hello,

I am using below code to implement a simple_action_server:

#include <ros/ros.h>
#include <actionlib/server/simple_action_server.h>
#include <robot_calibration_msgs/GripperLedCommandAction.h>

typedef actionlib::SimpleActionServer<robot_calibration_msgs::GripperLedCommandAction> led_actn_srvr_t;

class led_action
{

ros::NodeHandle nh;
led_actn_srvr_t ls;
std::string action_name;
public:

led_action(std::string name):
    ls(nh, name, boost::bind(&led_action::execute_cb, this, _1), false),
    action_name(name)
{
    ls.start();
}
void execute_cb(const robot_calibration_msgs::GripperLedCommandActionConstPtr &action)
{
}
};

int main(int argc, char** argv)
{
    return 0;
}

While compiling this code, I am getting below error:

/usr/include/boost/bind/mem_fn_template.hpp:184:7: note:   no known conversion for argument 1 from ‘led_action*’ to ‘led_action&’

I searched for the solution of this compilation issue, but not able to figure out the problem.

Can someone please help to solve this problem.

Saurabh

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2018-06-16 05:03:15 -0600

saurabh gravatar image

I got the solution for this problem. Actually what I found out is like, whenever we use any action in our code, and with that 7 messages are generated, as below:

  1. XXXGoal.msg
  2. XXXFeedback.msg
  3. XXXResult.msg
  4. XXXAction.msg
  5. XXXActionGoal.msg
  6. XXXActionFeedback.msg
  7. XXXActionResult.msg

So the problem here is that, we have to use XXXGoal.msg in the callback. But I was using XXXActionGoal.msg in the callback. And that why I was getting the compilation error.

Now I changed to void execute_cb(const robot_calibration_msgs::GripperLedCommandConstPtr &action) instead of void execute_cb(const robot_calibration_msgs::GripperLedCommandActionConstPtr &action). And it is compiling and I am able to use it.

edit flag offensive delete link more
0

answered 2018-06-14 03:28:40 -0600

marguedas gravatar image

It looks like your variables are not initialized, for example your node is never initialized. Did you try using a main function similar to the tutorial ?

int main(int argc, char** argv)
{
  ros::init(argc, argv, "my_led_action");

  LedAction my_led_action("my_led_action");
  ros::spin();

  return 0;
}
edit flag offensive delete link more

Comments

Hello Marguedas, thanks for your response. I tried with initialising the node too. But getting the same error.

saurabh gravatar imagesaurabh ( 2018-06-14 03:51:16 -0600 )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

2 followers

Stats

Asked: 2018-06-13 15:29:37 -0600

Seen: 152 times

Last updated: Jun 16 '18