# ros2/rviz architecture

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

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

## Overview

##### Main Components
- rviz2 Application Entry Point – The “rviz2” directory contains the main executable (main.cpp), change logs, scripts (e.g. for migrating from rviz1), and package definition files. It is the launcher and ties the system together when used with ROS 2.
- Core Libraries (rviz_common) – This module provides the fundamental abstractions for displays, panels, UI management, configuration, interaction, and transformation handling (including the default “IdentityFrameTransformer”). Its many header and source files, along with properties, panels, and view controllers, indicate that this layer defines the core interfaces and components.
- Plugin Modules (rviz_default_plugins) – This directory hosts a variety of plugins such as displays (Axes, Camera, Marker, etc.), tools, view controllers, and even a tf2-based transformer for frame transformations. It is the extensibility mechanism that developers can extend via the Plugin Development Guide.
- Testing and Visual Frameworks – The file tree includes directories for tests (rviz_rendering_tests, rviz_visual_testing_framework, etc.) which indicate an architecture that emphasizes modular testing, as well as visual testing integration.

##### Relationships and Interactions
- The primary data flow begins at the rviz2 executable, which initializes the core framework (rviz_common).
- The core framework is responsible for setting up the visualization window (using rviz_rendering) and loading plugins (from rviz_default_plugins) to create displays, panels, tools, and view controllers.
- There is a clear layered relationship:
– The “rviz2” layer calls into “rviz_common” for high-level functionality.
– “rviz_common” uses “rviz_rendering” to interact with the low-level graphical libraries (Ogre via rviz_ogre_vendor).
– Both core and rendering layers expose plugin interfaces, which are implemented in “rviz_default_plugins” (and developers can define additional ones via the plugin development and transformation libraries) to extend functionality.

##### Architectural Patterns
- Extensibility – Emphasize that the system is built to be extended by third-party developers (see the “Plugin Development” documentation) and highlight the pluggable transformation subsystem.

##### Relevant Technologies
- C++ is the core language.
- ROS 2 is the middleware integration.
- OGRE is the rendering engine (along with the rviz_ogre_vendor for integration).
- TF2 (and the pluggable alternative, such as the Identity transformer) for coordinate transformations.
- The build and test systems (e.g., CMake, colcon build) can be noted as part of the infrastructure supporting development.

##### Final Recommendations
- Detail every significant architectural element—don’t shy away from breaking the system into as many discrete components as can be reasonably inferred.
- Notes on extension points and dependencies so that future developers can quickly see where and how they can add features or swap out components.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Application Layer
    subgraph "Application Layer"
        A["rviz2 (Application Entry Point)"]:::entry
    end

    %% Core & UI Layer
    subgraph "Core & UI Layer"
        B["rviz_common (Core Framework)"]:::core
        C["Transformation Panel"]:::core
        IFT["IdentityFrameTransformer"]:::core
    end

    %% Plugin Layer
    subgraph "Plugin Layer"
        D["rviz_default_plugins (Plugin Modules)"]:::plugin
        TF["TFFrameTransformer"]:::plugin
    end

    %% Rendering Layer
    subgraph "Rendering Layer"
        F["rviz_rendering (Rendering Engine)"]:::rendering
        G["rviz_ogre_vendor (OGRE Glue)"]:::rendering
    end

    %% External Dependencies
    subgraph "External Dependencies"
        H["ROS 2"]:::external
        I["OGRE"]:::external
    end

    %% Testing Frameworks
    subgraph "Testing Frameworks"
        J["rviz2/test/"]:::test
        K["rviz_common/test/"]:::test
        L["rviz_rendering_tests/"]:::test
        M["rviz_visual_testing_framework/"]:::test
    end

    %% Connections
    A -->|"initializes"| B
    B <-->|"loads"| D
    B -->|"rendersVia"| F
    F -->|"integratesWith"| G
    B -->|"provides"| C
    C -->|"default"| IFT
    C -->|"plugin"| TF
    D -->|"offers"| TF
    A -->|"communicates"| H
    F -->|"drawsWith"| I
    A -->|"tests"| J
    B -->|"tests"| K
    F -->|"tests"| L

    %% Styles
    classDef entry fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
    classDef core fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef plugin fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef rendering fill:#D5F5E3,stroke:#196F3D,stroke-width:2px;
    classDef external fill:#D6EAF8,stroke:#1F618D,stroke-width:2px;
    classDef test fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;

    %% Click Events
    click A "https://github.com/ros2/rviz/blob/rolling/rviz2/src/main.cpp"
    click B "https://github.com/ros2/rviz/tree/rolling/rviz_common/"
    click D "https://github.com/ros2/rviz/tree/rolling/rviz_default_plugins/"
    click F "https://github.com/ros2/rviz/tree/rolling/rviz_rendering/"
    click G "https://github.com/ros2/rviz/tree/rolling/rviz_ogre_vendor/"
    click J "https://github.com/ros2/rviz/tree/rolling/rviz2/test/"
    click K "https://github.com/ros2/rviz/tree/rolling/rviz_common/test/"
    click L "https://github.com/ros2/rviz/tree/rolling/rviz_rendering_tests/"
    click M "https://github.com/ros2/rviz/tree/rolling/rviz_visual_testing_framework/"
```
