Think about how the server handles goal states and cleanup.
When an action server receives a preempt request, it sets the current goal state to preempted. This allows the server to perform any necessary cleanup or partial result reporting before stopping the goal execution.
Consider the meaning of each goal state.
The PREEMPTED state indicates that the goal was canceled or replaced before completion, which is exactly what happens when a preempt request is accepted.
void executeCB(const YourActionGoalConstPtr &goal) {
// ... some processing ...
// Check for preemption here
}Look for the method that detects a preempt request.
The method isPreemptRequested() returns true if the client has requested to preempt the current goal. The server should then call setPreempted() to acknowledge and stop processing.
Think about what the server must do to acknowledge preemption.
Detecting a preempt request is not enough; the server must call setPreempted() to change the goal state and stop processing. Without this call, the server continues as if nothing happened.
Consider what the client expects after preemption.
When a goal is preempted, the server stops sending feedback because the goal is no longer active. The result message is sent with a status indicating the goal was preempted, so the client knows the goal did not complete normally.
