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

*ActionServer cancel implementation

asked 2013-03-12 04:27:13 -0500

thebyohazard gravatar image

updated 2014-01-28 17:15:38 -0500

ngrennan gravatar image

I'm confused about how to implement cancelling in action servers. I'm under the impression that I'll need an ActionServer rather than a SimpleActionServer, but I'm hoping I'm wrong.

The actionlib detailed description page says that cancel request is a client action rather than a server action. It also shows a cancel request as the only way to transition to the preempting or recalling states. Yet the SimpleActionServer can recall goals upon receipt of a new goal. Is it just interpreting new goals as cancel requests and cancelling its own goals, or is a SimpleActionClient also sending a cancel message along with a new goal? Must I use a SimpleActionServer with a SimpleActionClient or could I have a specialized regular ActionServer with a SimpleActionClient?

Here's why I'm asking: I'm designing an action server. The client must be able to cancel active goals. However, no newly received goal should replace an active goal; instead the server should reject them. I'll need a special callback for cancelling goals where I stop motors and whatnot.

Thanks for your help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2013-03-12 06:12:41 -0500

vpradeep gravatar image

The SimpleActionServer is a wrapper on top of the ActionServer. Thus, the ActionServer is compatible with the SimpleActionClient. In your case, it sounds like the goal handling policy implemented in the SimpleActionServer doesn't suit your needs. Thus, it's totally reasonable to implement a derivative of the SimpleActionServer, or simply use the ActionServer directly.

Unfortunately, you cannot reject goals from client code while using the SimpleActionServer. This was a design decision to help simplify the API. However, internally, the SimpleActionServer can cancel a goal (as you noticed). If there is a pending goal and another goal is received, the SimpleActionServer cancels the original pending goal (See L271 of simple_action_server_imp.h). The SimpleActionClient is not sending a cancel in this case. Instead, the SimpleActionClient immediately forgets about the old goal, and tracks the new goal internally.

My suggestion would be to switch to the ActionServer. This works best when your application is already callback based, and it will give you the flexibility that you want. With the ActionServer, you can simply reject the goal if there's already another goal in project.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-03-12 04:27:13 -0500

Seen: 2,695 times

Last updated: Mar 12 '13