Topics stream data. Sometimes a node needs to ask a question, or start a long job.
Key idea
A service is one request and one reply, like asking a question. An action is for long jobs: you send a goal, get steady feedback, receive a result, and can cancel along the way.
| Tool | Pattern | Good for |
|---|---|---|
| Topic | Stream, many listeners | Sensor data, robot state |
| Service | Ask once, get one answer | "Reset the odometry", "what is the map?" |
| Action | Goal, feedback, result, cancel | "Drive to the kitchen", "move the arm there" |
Why it works
Picking the right tool keeps the robot responsive. A service call to a two-minute job would leave the caller with no news and no way to stop it.
Worked example: Pick one
Dock to the charger, which takes about a minute, and let the user stop it.
- Long, needs progress and a way to stop.
Answer: An action.
Common mistake
Using a service for a long task, so the caller waits with no progress and cannot cancel.