How ros2/rclcpp works
Main Components
• rclcpp (core library): Handles basic functionality such as nodes, publishers, subscriptions, services, parameters, clocks, timers, wait sets, and logging. It is the foundation that provides the interfaces most users include with “#include rclcpp/rclcpp.hpp”.
• rclcpp_action: Provides the abstractions for ROS 2 actions (clients, servers, goal handles) and related APIs.
• rclcpp_components: Manages the creation and registration of componentized nodes, enabling dynamic composition of nodes at runtime.
• rclcpp_lifecycle: Implements managed (lifecycle) nodes, with functionalities to control and monitor node states and transitions.
• ROS Middleware Interaction: Although not explicitly a “directory”, the library interfaces with ROS middleware (RMW) through an abstraction layer. Represent this middleware connection as a dedicated component.
File Structure for Architectural Relationships
• The core rclcpp module provides most of the header interfaces (for nodes, publishers, subscribers, etc.) and many of the source files implement these abstractions.
• The experimental and detail directories are placeholders for auxiliary or internal implementation details. You may choose to emphasize them as “Utilities” or “Internal Helpers” if needed.
Relationships and Data Flow
• rclcpp_components and rclcpp_lifecycle extend rclcpp by adding component-based and lifecycle management capabilities. Represent these as extended modules that integrate with the core.
• Connection between these libraries and ROS Middleware (RMW layer) to indicate that all higher-level abstractions eventually interface with the underlying ROS communication layer.
Important Architectural Patterns
• Modularity: The separation of rclcpp into different packages (core, action, components, lifecycle) is by design and should be highlighted.
• Abstraction Layers: The user-facing C++ API abstracts details of the ROS communication mechanism.
• Test and Documentation Driven: The extensive test directories (benchmarks, unit tests) show an architecture that emphasizes reliability and instrumented behavior.