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

Revision history [back]

click to hide/show revision 1
initial version

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.