Lesson reading
live
55 min
Start with the lesson question, connect the representations, and test the model with evidence.
Inspect the opening phenomenon
Predict what changes, then name the evidence.
Apply in the lab
Name the evidence before reading the answer.
Read only what helps
Then use the lab and recall check.
More when needed
Transcript and resources stay available below.
Course progress
Services, Actions, and Parameters
Decision challenge
Use the opening example to make a prediction, identify evidence, and explain which model supports it.
Choose an interface for a 40-second docking goal that needs feedback and cancellation.
Before
Choose an interface for a 40-second docking goal that needs feedback and cancellation.
During
Track communication shape, duration, feedback, and cancellation.
After
Explain why a docking action is not merely a slow service.
Lesson reading
live
55 min
Video script
draft
Transcript fallback
available
courses/ai-robotics/modules/04-programming-robot-systems-with-ros2/lessons/02-services-actions-and-parameters/video-transcript.md
Choose a ROS 2 Interface Lab
draft
30 min
Mastery check
live
7 questions / 10 min
# Transcript Docking takes forty seconds. The operator needs progress and a cancel button. Service or action? Use an action. A topic carries a continuing stream such as camera, lidar, or odometry. A service is one quick request and response, such as reset or query. An action owns a long-running goal: accept it, report feedback, return a result, and allow cancellation. A parameter configures a node, such as maximum speed or controller gains. Stream, quick answer, long goal, configuration. Classify the communication shape before choosing the ROS 2 interface.
Reading lab
Connect the lesson's words, diagrams, graphs, evidence, and equations.
A mobile robot must reach its dock. The operation takes about 40 seconds. The operator needs progress updates and must be able to cancel if a person blocks the route.
Choose before reading on: topic, service, action, or parameter?
The best answer is an action. Docking is a goal with a lifecycle: accepted, executing, producing feedback, then succeeded, aborted, or canceled. A service is designed for a short request and response—not a long process that may need interruption.

| Interface | Communication shape | Best for | Robot example |
|---|---|---|---|
| Topic | asynchronous publish/subscribe | continuous observations or state, often with several consumers | /scan, camera frames, odometry |
| Service | request → quick response | short operations that return an answer | reset odometry, query a map name |
| Action | goal → feedback → result, with cancellation | work that takes time and has a lifecycle | navigate, dock, manipulate |
| Parameter | named value owned by a node | configuration, tuning, and startup/runtime settings | max_speed, frame_id, controller gains |
Use this decision rule:
A service client usually waits for a server to perform a short computation and reply. ROS 2's official service guidance says services should return quickly and should not be used for long-running work that may need preemption.
An action exposes the lifecycle deliberately:
client -- goal --> action server
client <-- accepted/rejected -- server
client <-- feedback ----------- server
client -- cancel request -----> server (optional)
client <-- final result -------- server
Feedback answers “how is it going?” A result answers “how did it finish?” Cancellation requests that the server stop the active goal safely. These are different pieces of evidence and should not be collapsed into one delayed response.
The ROS 2 action design gives every accepted goal a state machine. Active states are ACCEPTED, EXECUTING, and CANCELING. Terminal states are SUCCEEDED, ABORTED, and CANCELED. A rejected goal never enters that state machine.
| Observation | What it proves | What it does not prove |
|---|---|---|
| Goal accepted | the server agreed to attempt this goal | that motion has started or will succeed |
| Feedback received | the server reports progress for this goal | that the feedback matches physical reality |
| Cancel accepted | the server agreed to begin cancellation | that cleanup and stopping are complete |
SUCCEEDED result | the server reports successful completion | physical safety unless separately observed |
ABORTED result | the server terminated the goal internally | the cause without logs and supporting evidence |
This separation prevents a common UI mistake: showing “done” immediately after goal acceptance rather than after a terminal result.
Imagine a warehouse robot:
/scan as a topic because measurements arrive continuously and localization plus obstacle avoidance both consume them./reset_odometry as a service because the caller makes one request and expects a quick acknowledgement./navigate_to_pose as an action because travel takes time, produces progress, and may need cancellation.max_speed as a parameter because it configures behavior; it is not a stream of drive commands.Ask what happens if the work lasts ten times longer than expected.
That makes duration, progress, and interruptibility architectural requirements—not implementation details.
Repeatedly polling a service for camera frames hides a continuous data stream inside repeated request/response calls. A topic states the true relationship and allows multiple subscribers.
max_speed=0.5 is configuration. “Drive forward now” is an operational command. Parameters should not disguise time-sensitive commands or event streams.
In ROS 2, each node maintains its own parameters. Values can be provided at startup with --ros-args -p, loaded from YAML, queried, changed, and monitored for parameter events. That machinery makes parameters useful for explicit node settings, but it does not turn them into a replacement for a topic, service, or action.
A discovered service or action server only proves an endpoint exists. Your evidence must still include response semantics, action status, feedback, result code, and robot behavior.
Before accepting an interface design, write down:
Classify each interaction:
Now explain each answer using communication shape—not merely the example name.
External sources are linked and cited for learning; no third-party text, figures, or footage are republished.
Defend interface choices using frequency, duration, feedback, cancellation, fan-out, and configuration semantics.
You are reviewing a delivery robot design. The team proposes a service for everything.
turtlesim for the CLI extensionFor each interaction, choose topic, service, action, or parameter and write one sentence of evidence.
The current design polls GetLatestCameraFrame ten times per second and calls DockRobot, a service that may block for two minutes.
Create an evidence table with columns: interface, success evidence, failure evidence, timeout, and operator response.
No ROS installation is required. Trace these events on paper or in a text file:
00 s client sends Dock goal
01 s server accepts goal
05 s feedback: 3.2 m remaining
12 s feedback: 1.6 m remaining
14 s obstacle appears
15 s client requests cancel
16 s server accepts cancel request
18 s server reports CANCELED
For every event, record:
Then change the final event to ABORTED. Explain how the operator response and evidence request should change.
If ROS 2 and turtlesim are available, inspect the action graph rather than controlling hardware:
ros2 action list -t
ros2 action info /turtle1/rotate_absolute
ros2 interface show turtlesim/action/RotateAbsolute
ros2 action send_goal --feedback /turtle1/rotate_absolute turtlesim/action/RotateAbsolute "{theta: 1.57}"
Capture the action name/type, goal fields, feedback, and terminal result. Do not treat terminal status alone as proof of a safety-critical physical outcome.
For a service comparison, inspect rather than repeatedly poll:
ros2 service list -t
ros2 service type /clear
ros2 service info /clear
ros2 interface show std_srvs/srv/Empty
Record the request type, response type, and server count. Service-event echoing requires introspection support to be enabled; absence of echoed traffic is therefore not automatically evidence that no calls occurred.
A strong submission should include these design decisions:
drive_now, grip_object, or stop_robot—it is probably disguising an operation.No ROS 2 installation or robot is required. Complete the classification and evidence table with a text editor, spreadsheet, or paper. The lesson transcript and decision table provide the same concepts as the video. A screen-reader user may describe each interface as a communication sequence instead of drawing arrows.
CANCELED?Design an interface contract for a one-minute grasp task. Define its goal, two feedback fields, terminal outcomes, cancellation behavior, one configuration parameter, and the physical evidence required before declaring success.