📄️ 2.1 Why Middleware?
In Chapter 1, we established the "Triad Architecture" how do these layers talk to each other? How does a high-level goal from the Commander translate into the low-level electrical signals that move the robot's joints?
📄️ 2.2 The Atomic Unit: Nodes & Graphs
ROS 2 applications are built from small, single-purpose programs called nodes [1]. A node is the "atomic unit" of ROS 2. Each node is responsible for a single task, such as controlling a wheel motor, reading a sensor, or planning a path. This modularity is a core design principle. Instead of one giant, monolithic program that does everything, a robot's intelligence is distributed across dozens of these small, independent nodes. This makes the system easier to debug, test, and reuse.
📄️ 2.3 The Python Bridge (rclpy)
While ROS 2 is built on C++, its primary interface for AI and machine learning engineers is Python. The ROS Client Library for Python, or rclpy, is the bridge that allows us to write ROS 2 nodes in Python [1]. As an AI engineer, rclpy is your gateway to the robot's nervous system. It's how you'll take the output of your models—predictions, plans, decisions—and inject them into the ROS 2 graph to be acted upon by the robot.
📄️ 2.4 Workspace Hygiene
As you start creating your own ROS 2 nodes, you'll need a way to organize, build, and manage them. A ROS 2 workspace is a directory that contains your ROS 2 packages. Proper workspace management, or "workspace hygiene," is essential for avoiding conflicts and ensuring that your code is portable and easy to share [1].