Ask Your Question

How do you cancel an actionlib action?

asked 2016-04-21 17:46:57 -0500

Cerin gravatar image

How does an actionlib client cancel an ongoing action?

The docs clearly explain how to code an actionlib server to react to a cancellation request and exit, but I can't find any example of how this is initiated by the client.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2016-04-21 18:25:48 -0500

ahendrix gravatar image

Each of the client APIs for the action clients has a cancel method. The full API documentation can be accessed through the Code API link on the main wiki page.

In the python action client, send_goal returns ClientGoalHandle which can be used to cancel the goal:

In the C++ action client, sendGoal returns a GoalHandle with a cancel method:

On the python simple action client, there is a cancel_goal method:

On the C++ SimpleActionClient, there is a cancelGoal method:

edit flag offensive delete link more

answered 2018-01-17 15:19:47 -0500

AndyZe gravatar image
edit flag offensive delete link more



This is no cancellation request in the link you've posted it.

CroCo gravatar image CroCo  ( 2021-11-06 15:20:50 -0500 )edit

answered 2021-11-06 15:20:24 -0500

CroCo gravatar image

The class actionlib::SimpleActionClient<> has this function cancelGoal(). In this Writing a Simple Action Client example, the time limit is set to 30 seconds. After that, the client just quits. unfortunately, the author didn't send cancel request and the server keeps running even though the client is no longer exist. You can check the server is running by rostopic echo /fibonacci/feedback which allows you to see the feedback.

if (finished_before_timeout){
    actionlib::SimpleClientGoalState state = ac.getState();
    ROS_INFO("Action finished: %s",state.toString().c_str());
    ROS_INFO("Action did not finish before the time out.");

    // add this line
    ROS_INFO("Goal has been cancelled");
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



Asked: 2016-04-21 17:46:57 -0500

Seen: 9,962 times

Last updated: Nov 06 '21