Robotics and Middleware · ROS 2 concept
ROS 2 Action
Also known as ROS action, action server, action client, .action, goal, feedback
A ROS 2 interface for long-running tasks: a client sends a goal to an action server, receives periodic feedback while it executes, can cancel or preempt it, and finally receives a result.
Explanation
Action types are defined in .action files with three parts: the goal (request), the result and the feedback. An action has one server and any number of clients for a given action name. As with services, several servers on the same name lead to undefined behaviour.
An action is built from ROS 2 primitives: goal, cancel and result services, plus feedback and status topics. This lets clients track goals, monitor progress and request cancellation, which is essential for operations such as navigating to a waypoint that may take seconds or minutes.
Actions carry more overhead than services because of the connection setup and monitoring involved, so short, non-cancellable requests should use services. Action servers must handle cancellation and preemption explicitly and report results consistently.
How it works
The client sends a goal through the goal service, and the server accepts or rejects it. While executing, the server publishes feedback messages and status updates. The client can request cancellation through the cancel service at any time. When the goal succeeds, aborts or is cancelled, the client obtains the outcome through the result service.
Automotive applications
- Navigating to a goal pose
- Executing a parking manoeuvre
- Running a calibration routine with progress reporting
- Long data-processing jobs
Example
A planner sends a park-in-bay-7 goal to a parking action server, which publishes feedback with the remaining distance every 100 ms. When a pedestrian appears, a supervisor cancels the goal, and the server stops the vehicle and returns a cancelled result.
An illustrative example: any figures in it are worked numbers, not measurements.
References
- Actions (ROS 2 documentation source) (opens in a new tab)
“In ROS 2, an action refers to a long-running remote procedure call with feedback and the ability to cancel or preempt the goal.”
- Understanding actions (tutorial) (ROS 2 documentation source) (opens in a new tab)
“the goal, cancel, and result services, and the feedback and status topics”
Definitions are original summaries. Standards text is not reproduced; follow the links for the official publications.