# ros2/rmw architecture

> Architecture diagram of the GitHub repository ros2/rmw, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ros2/rmw
- Repository: https://github.com/ros2/rmw

## Overview

##### Main Components

a. Core RMW Interface Layer
- Main API components visible in the include/rmw directory
- Related functionality into logical subsystems:
- Initialization & Configuration (init.h, init_options.h)
- Communication Primitives (publisher_options.h, subscription_options.h)
- QoS Management (qos_profiles.h, qos_policy_kind.h)
- Error Handling (error_handling.h, ret_types.h)
- Resource Management (allocators.h)

b. Implementation Support Layer
- This below the core interface
- Rmw_implementation_cmake component
- How it enables multiple RMW implementations

c. Validation & Security Layer
- Validation-related components (validate_namespace.h, validate_node_name.h)
- Security_options components

##### Component Relationships

- How the implementation support layer connects to potential RMW implementations
- Dependency flow from high-level APIs to lower-level components
- Relationship between QoS management and communication primitives
- How security and validation components interact with other parts

##### Specific Design Elements

Use the following visual elements:
- Blue rectangles for core API components
- Green rectangles for implementation support
- Yellow rectangles for validation and security
- Red rectangles for error handling
- Purple rectangles for resource management

##### Layer Organization

Top to bottom:

##### Important Details to Capture

- Event handling system (event.h, event_callback_type.h)
- QoS management system
- Security features
- Resource management
- Implementation flexibility

Left side:
- Core API components
- Type support
- Message handling

Center:
- Implementation abstraction
- Core middleware functionality

Right side:
- Security and validation
- Resource management
- Error handling

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef api fill:#a8d1f0,stroke:#333,stroke-width:1px
    classDef impl fill:#90EE90,stroke:#333,stroke-width:1px
    classDef validation fill:#FFE5B4,stroke:#333,stroke-width:1px
    classDef error fill:#FFB6C1,stroke:#333,stroke-width:1px
    classDef resource fill:#DDA0DD,stroke:#333,stroke-width:1px
    classDef security fill:#F0E68C,stroke:#333,stroke-width:1px
    classDef event fill:#98FB98,stroke:#333,stroke-width:1px
    
    subgraph "Public API Layer"
        INIT["Initialization & Config"]:::api
        COMM["Communication Primitives"]:::api
        QOS["QoS Management"]:::api
        TS["Type Support"]:::api
    end

    subgraph "Core Functionality"
        ERR["Error Handling"]:::error
        RES["Resource Management"]:::resource
        VAL["Validation"]:::validation
        SEC["Security Options"]:::security
        EVT["Event System"]:::event
    end

    subgraph "Implementation Support"
        IMPL["RMW Implementation CMake"]:::impl
        IMPL_DEFAULT["Default Implementation"]:::impl
        IMPL_AVAILABLE["Available Implementations"]:::impl
    end

    %% Relationships
    INIT --> ERR
    INIT --> RES
    COMM --> QOS
    COMM --> TS
    QOS --> VAL
    VAL --> SEC
    EVT --> ERR
    IMPL --> IMPL_DEFAULT
    IMPL --> IMPL_AVAILABLE

    %% Click Events
    click INIT "https://github.com/ros2/rmw/blob/rolling/rmw/include/rmw/init.h"
    click COMM "https://github.com/ros2/rmw/blob/rolling/rmw/include/rmw/publisher_options.h"
    click QOS "https://github.com/ros2/rmw/blob/rolling/rmw/include/rmw/qos_profiles.h"
    click ERR "https://github.com/ros2/rmw/blob/rolling/rmw/include/rmw/error_handling.h"
    click RES "https://github.com/ros2/rmw/blob/rolling/rmw/include/rmw/allocators.h"
    click VAL "https://github.com/ros2/rmw/blob/rolling/rmw/include/rmw/validate_namespace.h"
    click SEC "https://github.com/ros2/rmw/blob/rolling/rmw/include/rmw/security_options.h"
    click EVT "https://github.com/ros2/rmw/blob/rolling/rmw/include/rmw/event.h"
    click TS "https://github.com/ros2/rmw/blob/rolling/rmw/include/rmw/dynamic_message_type_support.h"
    click IMPL "https://github.com/ros2/rmw/tree/rolling/rmw_implementation_cmake/cmake"
    click IMPL_DEFAULT "https://github.com/ros2/rmw/blob/rolling/rmw_implementation_cmake/cmake/get_default_rmw_implementation.cmake"
    click IMPL_AVAILABLE "https://github.com/ros2/rmw/blob/rolling/rmw_implementation_cmake/cmake/get_available_rmw_implementations.cmake"

    %% Legend
    subgraph Legend
        L1["API Components"]:::api
        L2["Implementation"]:::impl
        L3["Validation"]:::validation
        L4["Error Handling"]:::error
        L5["Resource Management"]:::resource
        L6["Security"]:::security
        L7["Event System"]:::event
    end
```
