Ask Your Question
0

action result is published, but callback not being called

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

curranw gravatar image

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

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

curranw gravatar image

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

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

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: 2016-06-30 10:01:18 -0600

Seen: 143 times

Last updated: Jun 30 '16