Systems & software · topic D5 · 70 hours
ROS 2
The industry's de facto standard. But it is only a glue layer: it magnifies architectural problems just as it magnifies architectural skill. The real divide is not 'can you write a node' but 'do you know which layers squeeze you from both sides'.
What to learn
- Choosing among the five communication patterns: topics (broadcast, lossy), services (request-reply, blocking), actions (long tasks, cancelable, with feedback), parameters (configuration, not state)
- Topic queue semantics: publishers and subscribers each have a queue depth, and when it fills the oldest is dropped. 'Frames drop without any error' is ROS 2's most misread behavior
- launch and component-based deployment: why production dislikes spawning dozens of processes — intra-process zero-copy, centralized parameters, controllable startup order, controllable crash domain
- Writing nodes with rclcpp, not just rclpy: the GIL and GC make a Python node jitter inevitably at 1 kHz
- Interfaces as contracts: once a custom msg / srv / action field is published, don't change its semantics; adding fields must consider whether old packages can still parse
- Namespaces and remapping: running two robots on one machine, isolating conflicting topic names — and why this beats changing code for reliability
- The parameter system: launch parameters, parameter callbacks, layered parameter files (default → model → site), and why parameters must not be used as runtime state
- Measure before you change: what ros2 topic hz / bw, ros2 bag, and rqt_graph each answer, and when to use which
The lesson · plain words
ROS 2 is the robot world's lingua franca: nodes talk through topics/services/actions, everyone speaks the same protocol, and components snap together. The goal of learning it is not memorizing APIs but building the intuition of 'distributed debugging'.
This page focuses on two things: how messages flow, and how to debug when the flow breaks.
Three communication primitives, each with its own post
Topic: one-way streams, the standard for sensor data and command streams. Service: one question one answer, for configuration and queries. Action: long tasks with progress and cancellation — 'go to that room' style. Choosing the wrong primitive is the most common architectural ailment: piping a 30 Hz data stream through a service blows the queue instantly.
Watch the animation: messages flow along topics, and the publisher has no idea who is listening. This decoupling makes components swappable — and it also means going offline raises no error (click 'middle node gone' to see).
Interactive figure · drag it and see
The three debugging moves
ros2 topic list / hz / echo: whether data is flowing, whether the frequency matches, what the content looks like. ros2 node info: what this node actually publishes and subscribes to. ros2 daemon occasionally misbehaves and needs a restart — community-acknowledged daily life.
The debugging order for 'no data': is the publishing node alive → is the topic name right (namespace!) → are the QoS settings compatible (D6) → is it only visible on different machines/containers. Eighty percent of incidents die at the first two steps.
launch, parameters, and lifecycle
A launch file describes how the whole machine starts: which nodes, which parameters, which remaps. The parameter system lets the same node fit different robots — writing constants as parameters is a habit to form on day one.
D13 covers executors and lifecycle nodes in depth. For now remember one line: ROS 2's default behavior fits prototyping; productization requires actively setting QoS, executors, and log levels — the defaults are for learners.
The path of learning and using
Walk through the official tutorials basics + launch + urdf, about a week; then go straight into a project: build one sensor-to-control pipeline, and you will inevitably hit QoS, timestamps, and lifecycle — learn whatever you crash into.
Interview favorites: choosing among topic/service/action, the symptom of a QoS mismatch (no data and no error), and the essential difference between ROS 1 and ROS 2 (DDS decentralization, real-time friendliness).
Three questions — do you really get it?
1. Which primitive should carry a 30 Hz image stream?
- Aservice request-response
- Baction goal-feedback
- Ctopic publish-subscribe
Show answer
C. Continuous data streams are a topic's job. Services fit occasional requests; actions fit long tasks.
2. A subscriber receives no data and there is no error at all — the most likely cause?
- AThe program crashed
- BIncompatible QoS (e.g. reliable sub over unreliable pub) or a namespace mismatch
- CThe disk is full
Show answer
B. ROS 2's QoS mismatches disconnect silently — the number-one beginner trap. Compare both ends' QoS with ros2 topic info.
3. The price of node decoupling (publishers not knowing subscribers) is?
- ASilent failures: a dead downstream raises no error, so you must probe actively
- BLower performance
- CNo encryption possible
Show answer
A. Decoupling buys flexibility, and also 'broken without knowing'. Use topic hz and heartbeat monitoring as the safety net.
Keep going deeper
Links without a marker stay on this site; the rest point to the Chinese edition until its translation batch lands.
How it fails in the field
- Cramming all functions into one node with mixed frequencies — one stall stalls everything
- Writing a 1 kHz control node in Python, then blaming ROS 2's performance
- Using a service for an action that takes seconds, with the caller waiting synchronously — the whole node freezes; tasks like this belong to an action
- Stuffing uncompressed large images into topics and allocating a fresh block of memory per message — copies and GC push jitter up
You have learned enough when
The Chinese edition carries the full topic page for ROS 2, including the complete outline, depth requirements per career track, and further derivations: robotguide.dev/k/D5/.