Field guide
ROS 2 Action Cancellation: From Request to Terminal State
Check cancel scope, per-goal acknowledgements, terminal results, and physical-state evidence with a source-mapped ROS 2 action cancellation acceptance worksheet.
The short answer
A ROS 2 cancel acknowledgement is not a completed cancellation and is not proof that a robot has stopped. For each task, separate the cancel request, the response naming goals entering CANCELING, the terminal result, and any physical-state evidence required before another task may begin.
This distinction is explicit in the ROS 2 actions design: CANCELING is an active state that can accommodate application cleanup. CANCELED is a terminal state. The cancel response identifies goals that will be attempted to be canceled; status and result establish what happened afterward.
This guide provides a cancellation acceptance worksheet, a goal-selection example, and failure cases for an integration review. We inspected first-party design material and pinned source on November 4, 2026. We ran only the standalone Python selector example below. We did not run ROS nodes, cancel a real robot task, measure stopping time, or validate a safety function.
Track four different pieces of evidence
A user pressing Cancel should not make the interface silently mark the task complete. Record these separate observations:
| Evidence | What it establishes | What it does not establish |
|---|---|---|
| Client issued cancel request | The client attempted a request with a named scope | That the server received or accepted it |
| Cancel response includes the target goal | That goal entered cancellation processing according to the response | That cleanup finished or motion stopped |
| Terminal result for the same goal | The server’s final software outcome and action-defined result | An independently verified physical condition |
| Task-specific physical-state evidence | Whether the separately defined condition was observed | A general safety guarantee outside that condition |
The first three rows describe different protocol observations, not interchangeable success indicators. The fourth is our proposed integration requirement, not a ROS action protocol feature. Decide what evidence the application needs, who produces it, and when it becomes invalid. Do not infer it from a green task-status badge.
Keep the original goal UUID throughout this record. The actions design assigns goal-ID generation to the client and specifies a UUID. If a client reconnects or an operator retries, a newly created goal is a different protocol identity, even if its human-readable description is unchanged. Business-level duplicate prevention needs its own contract.
Check the scope before sending a cancel
The pinned CancelGoal definition defines four request policies. Here, zero ID means the all-zero goal identity, and time means the goal’s acceptance timestamp, not the wall-clock moment when the operator pressed Cancel.
| Goal ID | Timestamp | Defined selection policy |
|---|---|---|
| Zero | Zero | All goals |
| Zero | Nonzero | Goals accepted at or before that timestamp |
| Specific ID | Zero | That goal, regardless of acceptance time |
| Specific ID | Nonzero | That goal and goals accepted at or before that timestamp |
The last row is easy to misread as an AND filter. It is a union: the identified goal plus the timestamp-selected goals. If the intention is to request cancellation of one known goal, review the actual serialized request rather than assuming that a filled-in timestamp narrows its scope.
These are selection policies, not a promise that every selected goal can be canceled. The server still has to process the request, evaluate applicable goal state, and apply cancellation policy.
Reproduce the scope distinction without ROS
This deliberately small example models only the documented identity/time selection rule. The letters stand in for distinct nonzero UUIDs; None stands in for zero ID. Times are invented comparable acceptance times, with 0 reserved for the interface’s special policy. It does not implement the action state machine or predict the actual response for terminal, missing, or rejected goals.
goals = {"A": 10, "B": 20, "C": 30}
def selected(goal_id, cutoff):
if goal_id is None and cutoff == 0:
return sorted(goals)
return sorted(
name for name, accepted in goals.items()
if (goal_id is not None and name == goal_id)
or (cutoff != 0 and accepted <= cutoff)
)
for goal_id, cutoff in [(None, 0), (None, 20), ("C", 0), ("C", 20)]:
print(goal_id, cutoff, selected(goal_id, cutoff))
We executed this standard-library example. Its output was:
None 0 ['A', 'B', 'C']
None 20 ['A', 'B']
C 0 ['C']
C 20 ['A', 'B', 'C']
The final request selects A and B even though its explicit ID is C. Use the same distinction when reviewing an operator’s cancel-one versus cancel-group controls. This is a review aid, not a reason to send broad cancel requests to an operating system.
Interpret the response per goal
The same service definition specifies the response code and goals_canceling list:
ERROR_NONE: one or more goals enteredCANCELING; the list is nonempty.ERROR_REJECTED: no goals enteredCANCELING; the list is empty.ERROR_UNKNOWN_GOAL_ID: the requested identity does not exist; the list is empty.ERROR_GOAL_TERMINATED: the goal is already terminal and cannot be canceled; the list is empty.
For an integration review, compare the returned identities with the intended target, not just return_code. A successful group response is not a terminal-outcome receipt for every task the operator had in mind.
A terminal-state response also needs interpretation rather than a retry loop. The task might already have succeeded or ended another way before the cancel was processed. Obtain the result for that identity and reconcile it with the operation record. Do not rewrite a completed task as canceled merely because the user clicked Cancel around the same time.
If the client receives no response, retain an unresolved outcome. A local timeout does not prove rejection, cancellation, or absence of side effects. Our network and stale-data guide covers the separate communication-validity problem.
Inspect what the server actually does
In the reviewed Jazzy rclpy server, default_cancel_callback returns CancelResponse.REJECT. Merely using ActionServer does not establish that cancellation is accepted.
That implementation exposes is_cancel_requested by checking for STATUS_CANCELING. The goal handle’s canceled() method performs the transition associated with cancellation completion. Application behavior between those points matters: accepting a request is not the same operation as completing cleanup and reporting a terminal outcome.
Review the execute callback, cancel callback, scheduling arrangement, and any controller or device operation they invoke. Ask which code path observes cancellation, which work can still be in progress, and what evidence authorizes subsequent work. A callback existing in source is not a measured response-time bound. No maximum cancel latency is established by the source inspection in this guide.
Our lifecycle readiness guide addresses a different state machine: component startup and restart. A lifecycle state does not replace a per-goal cancellation result.
A cancellation acceptance worksheet
Use this proposed matrix in an isolated, non-actuating integration environment. The cases below are not executed ROS tests. Choose application-specific deadlines and escalation behavior before any separately authorized hardware exercise.
| Case | Proposed receiving-team check | Evidence to retain |
|---|---|---|
| Default or rejecting cancel callback | Show rejection without marking the task canceled | Callback configuration, request, response, goal UUID |
| Accepted cancellation with delayed cleanup | Keep cancellation pending until the terminal outcome is known | Response, cleanup events, terminal result |
| Task completes near the cancel request | Preserve the actual outcome instead of forcing a canceled label | Ordered server events and result for the same UUID |
| Reply lost or client disconnects | Mark outcome unresolved and reconcile before retrying work | Client attempt, server evidence, recovery decision |
| Cancel request contains ID and timestamp | Show the intended selection scope and returned identities | Serialized request, acceptance times, returned list |
| Server restarts before reconciliation | Do not assume pre-restart work or result remains available | Server session, surviving records, unresolved goals |
| New task requested while old task is canceling | Apply a documented admission policy rather than assuming preemption | Both goal identities, admission decision, old-task outcome |
| Software reaches a terminal state | Check any separately required physical condition before release | Result, condition observation, responsible decision owner |
A replacement goal is not evidence that the old task stopped. Specify whether the application rejects, queues, or otherwise handles competing work. The actions design leaves server behavior to its design; do not infer a universal preemption policy from the fact that the interface supports goals.
When measuring intervals, keep the clock basis explicit. A client send time and server event time cannot be subtracted meaningfully without a valid mapping. See the sensor timing and clock-domain guide before treating cross-host event differences as measured cancellation latency.
Keep one reconciliation record
Copy this proposed record into an acceptance review or incident report:
Action name, type, distribution, package revision:
Server configuration and session:
Business task identity and goal UUID:
Cancel request ID and timestamp:
Intended selection scope:
Response code and goals_canceling identities:
Terminal status and action-defined result:
Request, acknowledgement, and terminal event times:
Clock basis and uncertainty:
Cleanup outcome and unresolved side effects:
Physical condition required, observer, and observation:
Competing-goal admission and retry policy:
Observed ROS test result: NOT TESTED
Decision owner and outstanding evidence:
Preserve results promptly. The actions design describes configurable result caching and eventual removal, not an indefinite audit archive. Result availability after reconnect or restart must be verified in the actual configuration. Our incident-recording guide covers the adjacent evidence-retention task.
The useful acceptance claim is narrow: the named goal received the recorded response, reached the recorded terminal outcome, and met the separately specified release conditions in that configuration. Neither an accepted cancel request nor a terminal software state alone establishes emergency-stop performance or functional-safety certification.
For short request-response operations rather than actions, the service timeout and retry worksheet addresses duplicate effects, operation identity, and unresolved outcomes after a lost response.
Sources and evidence limits
First-party sources reviewed November 4, 2026:
- ROS 2 actions design. Used for goal identity, active versus terminal states, cancel-response boundaries, result retrieval, and caching. Architectural guidance, not measured implementation behavior.
CancelGoal.srv, pinned revision. Used for request-selection rules, response codes, andgoals_cancelingmeaning. The pinned file’s last-change commit is dated April 30, 2020; review date is not a claim of a new interface release.- Jazzy
rclpyaction server, pinned revision. Used for default cancellation rejection, cancel-request state inspection, and explicit completion transition. The pinned file’s last-change commit is dated July 8, 2026. Check your installed revision before adopting version-specific expectations.
The evidence layers, acceptance worksheet, reconciliation record, and retry recommendations are our engineering synthesis. Only the offline selector was executed. No ROS timing, robot motion, cleanup reliability, or safety outcome was measured.
Frequently asked questions
Does a successful ROS 2 cancel response mean the robot has stopped?
No. CancelGoal reports goals entering CANCELING, not a physical stop. Check the target goal, obtain its terminal outcome, and verify separately defined physical-state evidence.
Does every ROS 2 Python action server accept cancellation?
No. The reviewed Jazzy rclpy server uses a default cancel callback that rejects cancellation. Applications must deliberately implement and verify their cancellation behavior.
Can a cancel request select more than one goal?
Yes. The CancelGoal interface combines goal identity and acceptance timestamp. A nonzero goal ID with a nonzero timestamp selects that goal plus goals accepted at or before the timestamp.