- name
- ros2-actions
- description
- ROS 2 actions — goals, cancel, preemption, feedback, BT integration, and executor pitfalls (Nav2/MoveIt-style). Use when implementing action servers/clients, cancel handshakes, concurrent goals, or stuck RUNNING.
# ROS 2 Actions
## Contract
Goal → optional feedback → **exactly one** terminal: SUCCEEDED / CANCELED / ABORTED.
Do not fake cancel by succeeding. Do not detach work and report SUCCEEDED while hardware still moves — if you must, mark it `ponytail:` with ceiling + upgrade path.
## Server rules
- `goal_callback`: accept/reject quickly; no hardware.
- `cancel_callback`: accept only if you **will** stop; must be schedulable while execute runs (`ros2-executors`).
- `execute_callback`: poll cancel; on cancel **command safe stop**, then `canceled()`.
- Default: **one** active goal — reject or preempt the previous (MoveIt execute / Nav2 navigate style).
- Preempt: stop old goal to a known state, then start new.
## Client + BT / mission (Nav2-style)
- Tick/mission code uses **async** goals; on tree **halt** or preemption → **cancel** and wait for terminal (with timeout + local safe stop).
- Do not fire-and-forget goals from a leaf that can be halted.
- Feedback is for progress/UI; safety from state topics + server-side cancel.
## Threading
- Long execute: worker thread or queue; share cancel via atomic/mutex; never sync-wait other actions on the ST executor from execute without groups.
- Goal/cancel groups must not be blocked forever by execute (see `ros2-executors` pattern C).
## QoS / availability
Action = topics + services under `/action_name`. Lifecycle-inactive server ⇒ clients hang — check lifecycle first.
## Debug
```bash
ros2 action list
ros2 action info /foo --verbose
ros2 action send_goal /foo pkg/action/Type "{...}" --feedback
```
Server kill -9 ⇒ no result; clients need local timeouts.
Ver no GitHub