Real robots run many programs at once: one reads the lidar, one plans a path, one drives the motors. ROS 2 (Robot Operating System 2) is a free set of tools that lets them talk. It is not an operating system; it runs on top of one.
Key idea
Each program is a node that does one job. Nodes send messages on named topics. A publisher sends; any number of subscribers receive. Neither needs to know about the other, only the topic's name and message type.
Why it works
Splitting a robot into small nodes means each can be written, tested and restarted alone. Swap a real camera for a simulated one, and the rest of the robot never knows. That is why most research and many companies build on ROS 2.
Worked example: Message count
A lidar node publishes at 10 Hz. How many scans in a minute?
- $10 \times 60 = 600$.
Answer: 600.
Common mistake
Building one giant program, or forgetting that a topic with no publisher stays silent. A node waiting for a topic that nobody publishes just waits.
Try it
Getting set up
- ROS 2 runs best on Ubuntu Linux. Each ROS 2 release is tied to an Ubuntu version; the official documentation lists which goes with which.
- \$0: install it on a spare computer or in a virtual machine, and use the built-in turtlesim and the Gazebo simulator; no robot needed.
- About \$100 to \$200 more: a Raspberry Pi 4 or 5 on your mobile robot, talking to your laptop over Wi-Fi.
Work through the official beginner tutorials in order: install, turtlesim, nodes, topics. Run ros2 topic list and ros2 topic echo to watch messages go by. Then write a tiny publisher and subscriber of your own in Python.