ROS 2 Development Guide: Node Architecture and Sensor Integration

    Learn how ROS 2 organizes robot software into modular nodes and connects them through topics, services, and actions. This guide explains key differences between ROS 1 and ROS 2, covers ToF sensor, IMU, and motor driver integration for autonomous mobile robots, and outlines how containerization supports consistent deployment across hardware platforms.

    The Robot Operating System (ROS) is not an operating system in the conventional sense of managing hardware resources. It is an open-source middleware framework designed for robotics application development.

    ROS provides standardized tools and libraries for hardware abstraction, device drivers, and communication between software components. These capabilities help developers break complex robot functions into independent, reusable modules that can run separately. This modular approach reduces coupling and simplifies development.

    In autonomous mobile robot (AMR) systems, ROS provides a common framework for coordinating sensor acquisition, mapping, path planning, and low-level motor control.

    1. ROS Modular Architecture: Nodes and Communication

    Nodes are the building blocks of a ROS system. Each node performs a specific task: one might process data from a lidar or time-of-flight (ToF) sensor, another might plan a global route using an environment map, and another might translate velocity commands into motor control signals.

    Nodes can run independently, allowing developers to build and maintain individual functions without tightly coupling the entire system. ROS provides three primary communication mechanisms to connect these components.

    Topics: Continuous Data Streams

    Topics use a publisher–subscriber model and are well suited to continuous, one-way data streams.

    For example, a depth camera node can continuously publish 3D point cloud data to a topic. An obstacle avoidance node subscribes to that topic to receive updates without needing a direct connection to the camera’s internal implementation.

    This separation allows publishers and subscribers to evolve independently while sharing a defined message interface.

    Services: Request–Response Interactions

    Services use a client–server model for discrete, two-way interactions. A client sends a request, and the server returns a response. The client can wait for that response when synchronous behavior is needed.

    Typical examples include requesting the chassis battery level or asking a pan-tilt unit to move to a specified angle. Services are best suited to operations that can complete promptly, rather than tasks requiring extended execution and ongoing feedback.

    Actions: Long-Running Tasks with Feedback

    Actions handle tasks that take time to complete and may need to be canceled or superseded. Examples include navigating to a destination or executing a complex robotic arm trajectory.

    Actions combine topic- and service-based communication to provide goal handling, progress feedback, and cancellation. This lets a client monitor a task while it runs rather than waiting for a single final response.

    2. ROS 1 and ROS 2: Key Architectural Differences

    As robotics expanded into industrial and commercial applications, ROS 1’s limitations around real-time operation and security became more significant. ROS 2 was developed to address these requirements.

    ROS 1 and ROS 2 typically use separate runtime environments, but the ROS bridge can support communication and data exchange between compatible interfaces.

    Decentralized Discovery

    ROS 1 relies on the ROS Master for node registration and discovery. This introduces a centralized dependency: if the Master becomes unavailable, discovery and the establishment of new connections are affected, although existing connections may continue to operate.

    ROS 2 removes the Master and uses Data Distribution Service (DDS)-based discovery. Nodes can discover one another over the network without relying on a single central discovery node, improving architectural resilience.

    Real-Time Design and Quality of Service

    ROS 2 was designed with real-time requirements in mind. Achieving real-time behavior still depends on the operating environment and application implementation; it is not guaranteed simply by using ROS 2.

    DDS quality-of-service (QoS) policies give developers control over communication behavior, including reliability, durability, and history depth. These policies can be matched to the data being exchanged.

    For example, motor command communication may prioritize reliable delivery, while high-frequency IMU streams may tolerate occasional packet loss to favor timely updates. The appropriate choice depends on the system’s control and timing requirements.

    Security

    ROS 2 integrates DDS-Security mechanisms for authentication, access control, and encryption. When configured appropriately, these mechanisms help protect communication in commercial and industrial deployments, including networks that cannot be assumed trustworthy.

    Platform Support and Build Tools

    ROS 1 has primarily been associated with Linux environments, particularly Ubuntu. ROS 2 broadens cross-platform support to include Windows and macOS, while support for constrained or bare-metal targets depends on the specific implementation.

    ROS 2 also moves from ROS 1’s catkin build system to ament-based package builds, updating the tooling used to build and organize robotics software.

    3. Integrating Core Perception and Control Components

    ToF depth sensors, inertial measurement units (IMUs), and motor drivers provide essential perception and motion capabilities in AMRs. Integrating them into ROS 2 involves translating hardware-specific data and commands into standard message interfaces.

    ToF Depth Sensor Integration

    ToF cameras estimate depth by measuring the travel time of emitted light. A ROS 2 integration typically uses a driver node to acquire sensor data and publish it in standard formats:

    • sensor_msgs/Image for depth images
    • sensor_msgs/PointCloud2 for 3D point clouds

    The driver should also expose configuration parameters where supported by the hardware. These may include exposure time, frame rate, and filtering thresholds, allowing developers to adjust acquisition and processing behavior without changing the driver implementation.

    Standard message formats make the sensor output easier to consume in downstream perception and obstacle avoidance nodes.

    High-Precision IMU Integration

    An IMU measures acceleration and angular velocity along three axes. The standard ROS message type for this data is sensor_msgs/Imu.

    Beyond publishing measurements, an integration may include an extended Kalman filter (EKF) in the driver or in a separate processing node. Filtering and sensor fusion can reduce the effects of noise and help estimate orientation, often represented as a quaternion. They do not, by themselves, eliminate all sources of drift.

    Accurate IMU data and orientation estimates are important inputs for subsequent odometry fusion and localization.

    Motor Control and Chassis Integration

    The motor control node connects high-level planning to the physical chassis. It typically subscribes to velocity commands using geometry_msgs/Twist, converts the requested linear and angular velocities into target wheel speeds, and sends commands to the motor drivers over a serial connection or CAN bus.

    For a differential-drive chassis, this means calculating the target speeds of the left and right wheels.

    The node also reads encoder measurements at regular intervals, calculates wheel-based odometry, and publishes nav_msgs/Odometry messages. This provides motion feedback that other parts of the robot software can use for localization and navigation.

    Together, command handling and encoder feedback form the interface between the ROS 2 software stack and the mobile platform.

    4. Containerization for Production Deployment

    Moving from a prototype to production introduces challenges in dependency management, hardware compatibility, and environment consistency. Docker containers can help package ROS 2 integrations into repeatable deployment environments.

    Container images can bundle sensor drivers, dependency libraries, and communication configuration. Providing images for different functional subsets also allows developers to deploy the components required by a particular robot configuration.

    Support for CPU architectures such as x86_64 and ARM64 helps maintain consistent software environments across supported target platforms. Containers do not remove all hardware dependencies, but they reduce the amount of repeated environment setup required on each device.

    For organizations managing robot fleets or coordinating data with cloud systems, container platforms and monitoring services can also support an edge–cloud operations model. Baidu AI Cloud is one platform referenced for these capabilities; applicability depends on service availability and deployment requirements. The underlying approach is to connect edge-side ROS 2 workloads with cloud-based management and monitoring.

    Conclusion

    ROS 2 combines modular nodes, standardized communication interfaces, and DDS-based middleware to provide a flexible foundation for robotics development.

    For AMRs, consistent integration patterns for depth sensors, IMUs, and motor drivers help connect perception, localization, planning, and motion control. Containerization complements this architecture by packaging dependencies and configuration into more reproducible deployment environments.

    Together, these practices reduce integration overhead and let developers focus more attention on application algorithms, helping move AMR systems from prototype development toward production deployment.