Unit 05 · lesson
Choose the Communication Pattern
ROS 2 gives nodes several ways to interact.
The first question should not be "which command do I remember?"
Ask what kind of interaction the system needs.
Diagrams open at a readable shape-aware scale. Zoom or expand when you need more detail.
Choose a ROS 2 communication pattern from the interaction shape
Topics, services, parameters, and actions solve different coordination problems.
- NEEDidentify stream, request, configuration, or long-running goalclassify
- TOPICongoing typed streamor
- SERVICE / PARAMone request-response operation or node configurationor
- ACTIONgoal with feedback, result, and cancellationverify
- CONTRACTinteraction shape matches the system requirement
Topic
Use a topic when publishers send a continuing stream of typed messages and subscribers receive updates.
Examples: velocity commands, sensor data, pose updates.
Service
The official service tutorial describes a call-and-response model. A client sends a request to a service server and receives a response.
Examples: clear the Turtlesim screen, spawn a turtle, request one operation.
Parameter
The parameter tutorial describes parameters as node configuration values or settings.
Examples: Turtlesim background color, use_sim_time, scale values.
Action
The action tutorial describes long-running work using goal, feedback, and result. Actions are cancelable and are built using topics/services underneath.
Example: rotate Turtlesim toward a target heading while receiving progress and a final result.
Decision drill
Classify each need and explain why:
- laser scan updates arriving many times per second;
- ask a node to reset once;
- change a node's background color setting;
- tell a mobile robot to navigate toward a location and report progress.
Checkpoint
Do not answer with only four labels. For each one, name the interaction shape that made you choose it.