Ubuntu Linux for Robotics · Lesson 88 of 96
Distributed systems
Several computers in one ROS 2 system: time sync, discovery server and networking.
Estimated time · 60–90 min
Learning goals
What you will understand
- Explain distributed systems in your own words
- Use it in a small workstation example
- Verify the result instead of assuming it worked
Understand the idea first
The mental model
A robot may have several computers (a controller, a perception computer, an operator laptop). They must agree on time (chrony or PTP), on the DDS domain and RMW, and they must be able to reach each other on the network. Use static addresses or names (/etc/hosts) so they do not change.
When multicast is unreliable use the Fast DDS Discovery Server: run it on one machine (fastdds discovery --server-id 0) and set ROS_DISCOVERY_SERVER on the others. Check clocks with chronyc tracking, and use ros2 topic delay to see message age across machines.
Guided lesson
Work through these steps
- 1.
Open a terminal and record the current state before changing anything.
- 2.
Read the distributed systems commands and predict what each one does.
- 3.
Run the commands one at a time and compare each output with your prediction.
- 4.
Write the commands that worked in a setup note you can repeat later.
Worked example
Read it before you run it
sudo apt install chrony
# Install a time synchronization service.
chronyc tracking
# Check this machine's clock offset.
fastdds discovery --server-id 0
# Run the discovery server on the main computer.
export ROS_DISCOVERY_SERVER=192.168.1.10:11811
# On every other machine: use that server.
ros2 topic delay /scan
# Measure how old messages are when they arrive (needs synchronized clocks).What the example is doing
- 1.Lines without sudo only inspect or change files you own; sudo authorizes a system-wide change.
- 2.Read command output before moving to the next line. Stop if names, versions, disks, or paths differ from the lesson.
- 3.Comments beginning with # explain safety checks and are not executed by the shell.
Watch it run · Messages between nodes
See what this code does
The terminal types this lesson's practice solution and runs it. The scene shows the kind of robot behaviour that code drives. It plays by itself and loops.
Demo for Distributed systems. Expected result: Reference ID, System time and offset lines
Practice code
Now type it yourself
Open a terminal, run the starter line by line (or save it as practice.sh and run bash practice.sh), and replace every TODO with your own command.
# TODO: print the clock synchronization status with chronyc trackingExpected output
Reference ID, System time and offset linesStuck? Show the full solution (try it yourself first)
chronyc trackingExpected result
How you know it worked
- Each command completes without an unexplained error.
- Your notes contain the command, the important output, and what it proves.
Practical exercise
Apply the lesson
Connect two computers with the discovery server, check both clocks with chronyc, run a talker and a listener across them, and measure the message age with ros2 topic delay.
Before you continue
- You recorded the starting state
- Every command and output is understood
- The change can be repeated from your notes
If something goes wrong
Check ownership and permissions first. Do not add sudo unless the command changes a documented system location.
Check spelling, Ubuntu version, enabled repositories, and whether the previous installation command succeeded.