actionlib::ActionClient - How to save the GoalHandle of the client to control the goal evaluation
I need to send the Goal to ActionServer and want to save the GoalHandle reference to be able to controll the further evaluation. I am trying to do it like this:
actionlib::ActionClient<communication::assignmentAction>::GoalHandle my_goal_handle = this->client.sendGoal(goal, boost::bind(&cAssignment::doneCallBack, this));
However, this gives me a runtime error by evaluation.
The relevant part of my code is provided below:
typedef actionlib::ActionClient<communication::assignmentAction> tClient;
class cAssignment{
public:
cAssignment();
virtual ~cAssignment();
void startAssignment();
void doneCallBack();
void cancel();
private:
tClient client;
communication::assignmentGoal goal;
actionlib::ActionClient<communication::assignmentAction>::GoalHandle my_goal_handle;
};
cAssignment::cAssignment(communication::assignmentGoal goal):
my_goal_handle(),
client("/assignment"){
this->goal = goal;
}
void cAssignment::startAssignment(){
this->client.waitForActionServerToStart();
my_goal_handle = this->client.sendGoal(goal, boost::bind(&cAssignment::doneCallBack, this));
}
void cAssignment::cancel(){
this->my_goal_handle.cancel();
}
void cAssignment::doneCallBack(){
std::string str = my_goal_handle.getResult()->result.data.c_str();
... some code ...
}
cAssignment::~cAssignment(){}
it would probably help if you would include the actual error in your post.
Error description: