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.

Diagram comparing topics, services, parameters, and actions by the kind of interaction they solve.
Diagram comparing topics, services, parameters, and actions by the kind of interaction they solve.

Diagrams open at a readable shape-aware scale. Zoom or expand when you need more detail.

Concept flow

Choose a ROS 2 communication pattern from the interaction shape

Topics, services, parameters, and actions solve different coordination problems.

  1. NEEDidentify stream, request, configuration, or long-running goal
    classify
  2. TOPICongoing typed stream
    or
  3. SERVICE / PARAMone request-response operation or node configuration
    or
  4. ACTIONgoal with feedback, result, and cancellation
    verify
  5. 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:

  1. laser scan updates arriving many times per second;
  2. ask a node to reset once;
  3. change a node's background color setting;
  4. 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.