ROS 2 and DDS architecture
ROS 2 does not implement its own mechanism for transmitting data over the network — that part is handled by an industry standard called DDS (Data Distribution Service), which has been used in aviation, defense, and finance for its high reliability.
ROS 2 stands on top of DDS, providing a familiar API layer (publisher, subscriber, service...) so you don't have to work directly with the complex concepts below. This is the biggest difference compared to ROS 1 — which wrote its own entire communication layer and needed a central process (roscore) to coordinate.
Why doesn't ROS 2 need roscore?
ROS 1 has a central server (roscore) for nodes to find each other. If it dies, the whole system loses communication. ROS 2 does away with that server: nodes discover each other via DDS. This is called discovery.
Each node "broadcasts announcements" periodically. Nodes that receive an announcement with a matching topic and message type automatically connect. See model below.
What layers does the data go through?
You write code on the top layer. Each layer below does a more specific job. When published, data goes down; when received, it goes up.
The code below the model frame changes to match the position of the dot: the code for the layer containing the dot is shown (simplified for easy visualization, not the actual function signature of rcl/rmw). Click "Send a message" then follow.
Four layers, each with its own job
| layer | Role | Where you encounter it |
|---|---|---|
| Your code | API: publisher, subscription, service | rclpy (Python), rclcpp (C++) |
| rcl | C core is common to all languages | No direct calls |
| rmw | Abstraction layer wrapping a specific DDS implementation | Variable RMW_IMPLEMENTATION |
| DDS | Discovery, data transfer, QoS | Fast DDS (Humble default), Cyclone DDS |
How to isolate network: ROS_DOMAIN_ID
Multiple robots can run on the same network. To avoid this robot's node talking to the other robot, each group sets a separate domain using the variable ROS_DOMAIN_ID. Try changing the domain of each node:
Two nodes with different ROS_DOMAIN_ID values will not see each other, even if running on the same machine. When "can't see topic" in terminal, check domain first.
Try it
echo $ROS_DOMAIN_ID
echo $RMW_IMPLEMENTATION
If the variable is empty, ROS 2 uses the default value: domain 0 and the installation's default DDS.