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

How to cancel goals from within an action server?

asked 2016-05-03 20:53:11 -0500

Cerin gravatar image

An action server exposes the hook cancel_all_goals() to clients can clear any running actions. However, how would you do this from within the server itself? I can't find any equivalent method in the SimpleActionServer instance.

I'm trying to write an action server that manages several different "classes" of pre-emptivable actions, and the client doesn't need to be aware of any running actions, so to simplify access, I want the server to automatically cancel any actions its running if a client starts a new one.

I tried instantiated a SimpleActionClient inside the server to connect to itself and cancel_all_goals() the way a client would, but when I do this the call to cancel_all_goals() hangs indefinitely, even when there are no actions running.

edit retag flag offensive close merge delete

Comments

The SimpleActionServer automatically preempts the current goal if a new one arrives. Is this behavior not enough?

Javier V. Gómez gravatar image Javier V. Gómez  ( 2016-05-04 04:04:43 -0500 )edit

No. I have a node with multiple action servers, one for each action, so one needs to preempt any action running on other servers.

Cerin gravatar image Cerin  ( 2016-05-04 09:11:18 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2016-06-27 06:55:19 -0500

rbaleksandar gravatar image

As @Javier mentioned in the comments the cancellation of a goal is done automatically. In order to handle multiple action servers at once you have to create a minimalistic SimpleActionClient for each action server (except for the one that cancels all of the other servers). Such a client will have only one task namely sending an empty goal of type X to the server which processes the respective action. By doing so you are exploiting (in a perfectly decent manner) the automatic preemption of the SimpleActionServer so each of the other action servers will receive it, do nothing but also cancel the goal each is currently executing. I would suggest (I'm also about to test it with my own code) that you trigger a cancel request using all the action clients and send to all the respective action servers. The triggering itself needs to be done inside the callback of the action server that needs to cancel all other servers.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-05-03 20:53:11 -0500

Seen: 3,279 times

Last updated: Jun 27 '16