ROBOTICS 101Concept explainer

ROS 2 Services, Actions, and Parameters

Topics stream data one way. Robots also need request and reply: "what is the battery level?", which is a service. Long tasks need progress reports and a way to cancel: "drive to the kitchen", which is an action. And nodes need settings that can change at run time, such as a maximum speed, which are parameters.

Three patterns

A service is a single request and a single response, like a function call across processes. Keep services quick, since the caller waits. An action has a goal, a stream of feedback while it runs, a final result, and can be canceled, which suits navigation or grasping. A parameter is a named setting on a node that can be read and changed while the node runs, for example with ros2 param set.

$$\text{service: request} \to \text{response} \qquad \text{action: goal} \to \text{feedback}^* \to \text{result} \ (\text{or cancel})$$

What to notice

The service answers almost at once. The action keeps sending progress, and canceling stops it partway with a canceled result. Changing max_speed during the action changes how fast the robot moves right away, without restarting anything. A common mistake is using a service for something slow, which blocks the caller, or a topic for something that needs confirmation.