What is an action in ROS2?
Atlasbot · 16/8/2026 · 10 min read
The command "move robot to coordinate (5, 3)" is not the same as "add two numbers" — it can take tens of seconds, the user wants to know where the robot is approaching (speed), and may need halfway if changing minds. This is a problem where both Topic and Service (returning only a single result, no progress, and blocks while waiting) do not neatly process — Action to properly solve this problem.
Key concepts
Action combines all three previously learned concepts into a unified mechanism:
- Goal— target sent at start (like Service request sent), e.g. "move to coordinates (5, 3)"
- Feedback — progress data is sent continuously while the task is running (like a Topic), e.g. "40% gone, 3m from destination"
- Result — final result when the task is complete, failed, or cancelled (Service - like response)
Unlike Service, Action's client sends the completed goal unblocked — which continues to receive torrential feedback while the goal is in progress, and has the option to cancel (cancel) the running goal at any time if necessary.
In summary: Use Topic for continuous flow data Service for a short action with immediate results Action for long, progress - sensitive and potentially abortive tasks — which is exactly the Nav2 mechanism used to receive the "move to a point" command from RViz or code.
How it works
Action Client Action Server
│ send Goal ("go to (5,3)") │
├──────────────────────────────────────►│ start execution
│ │
│◄──────────── Feedback (20%) ───────────┤
│◄──────────── Feedback (55%) ───────────┤
│◄──────────── Feedback (90%) ───────────┤
│ │
│◄──────────── Result (success) ─────────┤
Invoking an action that is available from the command line, observing the feedback directly on the terminal:
ros2 action list # list active action
ros2 action send_goal /navigate_to_pose nav2_msgs/action/NavigateToPose \
"{pose: {pose: {position: {x: 5.0, y: 3.0}}}}" --feedback
The --feedback flag causes the terminal to print continuously all progress messages received until the action completed — correctly stream the goal → feedback → result described above.
Technical details
Parameters
A goal action is always in the correct 1 of the following states at a time — proper checking of the final state is mandatory before considering the task as "successful":
| Status | Meaning |
|---|---|
PENDING | Goal sent, not accepted by server |
ACTIVE | Server executing target |
CANCELING | Client requesting abort, server stopping |
SUCCEEDED | Successfully completed |
ABORTED | Self-destruct server failed during execution |
CANCELED | Canceled on client request |
Protocol
At the bottom level, Action is actually assembled from learned blocks: 2 Service (1 for sending goal + acceptance confirmation, 1 for sending cancellation requests) and 2 Topic (1 for server continuous feedback, 1 for state/end result) — is not a completely new mechanism at the DDS level, but a convenient API layer that re-packages Service + Topic in accordance with the goal-feedback-result convention. Full details on how to manage this internal state are available in Action in the ROS2 Communication section.
Practical applications
In addition to Nav2's aforementioned NavigateToPose, action is well suited for AMR's auto-docking task — client sends the goal "to charge", server continuously reports feedback on the remaining distance to the charging station, and importantly can abort midway if the system detects a person/obstacle unexpectedly appearing on the way to charge — the possibility of aborting safely midway is the reason action is so much more suitable than service for physical locomotion tasks that may need to be stopped urgently at any time.
Practical example
$ ros2 action send_goal /navigate_to_pose nav2_msgs/action/NavigateToPose \
"{pose: {pose: {position: {x: 2.0, y: 1.0}}}}" --feedback
Output:
Waiting for an action server to become available...
Sending goal:
pose: ...
Goal accepted with ID: 8f3a2b1c...
Feedback:
distance_remaining: 4.85
Feedback:
distance_remaining: 2.10
Feedback:
distance_remaining: 0.32
Result:
error_code: 0
Goal finished with status: SUCCEEDED
distance_remaining decreases with each feedback indicating that the robot is actually approaching the destination — status: SUCCEEDED at the end is mandatory to check in the code (not just assuming "send the goal and the robot is there"), as the goal can perfectly end with ABORTED if the robot encounters an impossible obstacle.
Common mistakes
- Without checking the final result state, the assumption always succeeds — the code sends only the goal and then passes, without checking that
statusreturns asSUCCEEDEDorABORTED/CANCELED— resulting in the logic behind running even though the real-world task has failed. - Server fails to properly process the— cancel request if the server-side code does not check the cancellation flag periodically in the goal execution loop, the goal continues to run even though the client has sent a — cancel request with a physical locomotion task, which can be a serious safety issue.
- Name or action type mismatch between client and server — resembles a Topic/Service error, no explicit error message, simply client never finds the corresponding server.
- Sending multiple goals consecutively without canceling the old goal — some action servers process only 1 goal at a time; sending a new goal while the old goal is incomplete may be rejected or cause unwanted behavior depending on how the server is programmed to process the overlapping goal.
Conclusion
Action is the most complete of the Topic/Service/Action — triad combining target submission, continuous progress monitoring, and safe midway cancellation, suitable for all long-running physical locomotion tasks by robots. This is also the last article of the ROS2 Basic — column that is sufficiently conceptual to delve into the technical details of each communication mechanism in the next ROS2 Communication.
Get new articles and lessons by email
When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.
Unsubscribe any time with the link in each email. See our Privacy policy.