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

How do you cancel an actionlib action?

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

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
3

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

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: http://docs.ros.org/jade/api/actionli...

In the C++ action client, sendGoal returns a GoalHandle with a cancel method: http://docs.ros.org/jade/api/actionli...

On the python simple action client, there is a cancel_goal method: http://docs.ros.org/jade/api/actionli...

On the C++ SimpleActionClient, there is a cancelGoal method: http://docs.ros.org/jade/api/actionli...

edit flag offensive delete link more
0

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

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());
}else{
    ROS_INFO("Action did not finish before the time out.");

    // add this line
    ac.cancelGoal(); 
    ROS_INFO("Goal has been cancelled");
}
edit flag offensive delete link more
0

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

AndyZe gravatar image
edit flag offensive delete link more

Comments

1

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

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

Question Tools

2 followers

Stats

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

Seen: 13,245 times

Last updated: Nov 06 '21