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

action result is published, but callback not being called

asked 2016-06-30 10:01:18 -0500

curranw gravatar image

updated 2016-06-30 11:45:53 -0500

I must have set up my callback wrong, but I've followed the tutorials and cannot find the issue.

It's a relatively simple example.

typedef actionlib::SimpleActionClient<face_detector::FaceDetectorAction> ActionClient;

ValveInspection::ValveInspection()
{
    valve_client = new ActionClient ("valve_inspection_classifier", false);
}

void ValveInspection::activeCb()
{
    cout << "Active!" << endl;
}

void ValveInspection::doneCb(const actionlib::SimpleClientGoalState& state, const face_detector::FaceDetectorResultConstPtr& result)
{
    cout << "Got here!" << endl;
    cout << result->face_positions.size() << endl;
}

void ValveInspection::requestValves()
{
    face_detector::FaceDetectorGoal goal;
    valve_client->sendGoal(goal, boost::bind(&ValveInspection::doneCb, this, _1, _2),boost::bind(&ValveInspection::activeCb, this), ActionClient::SimpleFeedbackCallback());
    cout <<"Sent goal!" << endl;
}

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

  ValveInspection* vi = new ValveInspection();

  ros::Rate r = ros::Rate(1);
  while(ros::ok())
  {
    vi->requestValves();
    r.sleep();
  }
}

If I subscribe to /valve_inspection_classifier/result, I get results. However, the callback is not being called.

My output from the couts is only:

Sent goal!
Sent goal!
Sent goal!
Sent goal!

So the activeCb and doneCb are not being called. Can someone shed some light on this?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-06-30 11:49:51 -0500

curranw gravatar image

updated 2016-06-30 11:53:28 -0500

Don't forget your ros::spinOnce() if you are going to use a while loop!

Reference

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

  ValveInspection* vi = new ValveInspection();

  ros::Rate r = ros::Rate(1);
  while(ros::ok())
  {
    ros::spinOnce();
    vi->requestValves();
    r.sleep();
  }
}
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2016-06-30 10:01:18 -0500

Seen: 406 times

Last updated: Jun 30 '16