# introlab/rtabmap architecture

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

- Interactive diagram: https://gitdiagram.com/introlab/rtabmap
- Repository: https://github.com/introlab/rtabmap

## Overview

##### Main Components
- Core SLAM Engine: Represented by the “corelib” directory, this is the heart of the system where the SLAM algorithms, data capture, sensor fusion, odometry, loop closure detection, graph optimization, and mapping are implemented.
- Sensor Input Modules: Indicate how various sensor types are supported (cameras – RGB, depth, stereo; lidars; IMU, etc.). Subdirectories in “corelib” (e.g., camera, odometry, lidar, imufilter) show these integrations.
- Data Storage and Database: Highlight the support for map storage and database interactions (for example, the use of SQLite in corelib, the backward compatibility SQL files, and database schema resources).
- User Interfaces:
– Desktop GUI: “guilib” forms the front-end for desktop interaction and visualization.
– Mobile Interfaces: “app/android” and “app/ios” show native mobile applications that utilize the same core.
– ROS Nodes and Integration: Mention the ROS package (as per the README and ROS binary instructions).
- Utility Tools and Examples: The “tools”, “examples”, and “utilite” directories contain utilities for calibration, data recording, visualization, and testing of functions.
- Build and Deployment Infrastructure: Notice the CMake build system (“CMakeLists.txt” and cmake_modules), multiple Dockerfiles (in the “docker” directory), as well as CI configurations from GitHub and Appveyor.

##### Relationships and Data Flow
- Sensors (camera, LiDAR, IMU) feed raw data into the Sensor Input Modules.
- The Core SLAM Engine (corelib) processes the incoming sensor data – extracting features, computing odometry, detecting loop closures, and updating the map representation.
- The processed data (e.g., visual graphs, global map, and intermediate representations) is then stored in local databases.
- GUIs (guilib and mobile apps) and ROS nodes query this core engine to update the user’s visualization and interact with the mapping process.
- Utility tools and example applications serve as clients to showcase data capture, calibration, export, and reprocessing functionalities.
- Build scripts, Docker configurations, and CI pipelines ensure that the system is tested and deployed across multiple platforms and OS distributions.

##### Important Architectural Patterns
- Modular Design: Each core functionality (sensor input, algorithm processing, GUI layers, tools) is separated into a different module or library (i.e., corelib, guilib, app, tools, utilite). This separation supports maintainability and cross-platform development.
- Cross-Platform and Multi-Interface: The project supports multiple front-ends (desktop, mobile, ROS) interfacing to the same core SLAM engine, reflecting an MVC-like separation (model – core algorithms; view – GUI; controller – mobile/ROS integration).
- Extensibility: The structure (with directories such as “cmake_modules” and “tools”) indicates that new sensor drivers, new optimization techniques, or additional processing modules can be plugged in relatively easily.

##### Relevant Technologies and Frameworks
- C++ for the core and library implementations.
- CMake as the build system.
- Mobile development stack for Android (Java/C++ via JNI) and iOS (Objective-C/Swift and C++ bridging).
- ROS integration (node packages, binary packages for ROS 1/ROS 2).
- Docker for containerized testing and deployment.
- External libraries – for example, OpenCV, PCL, Eigen, and third-party libraries like “glm” for 3D math.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Sensor Modules Subgraph
    subgraph "Sensor Modules"
        CAM["Camera Modules"]:::sensors
        ODO["Odometry Modules"]:::sensors
        LIDAR["Lidar Modules"]:::sensors
        IMU["IMU Modules"]:::sensors
    end

    %% Core SLAM Engine Subgraph
    subgraph "RTAB-Map Core (corelib)"
        CORE["Core SLAM Engine"]:::core
    end

    %% Data Storage Subgraph
    subgraph "Data Storage"
        DB["Map Database"]:::db
    end

    %% User Interfaces Subgraph
    subgraph "User Interfaces"
        DESKTOP["Desktop GUI (guilib)"]:::ui
        MOBILE["Mobile Apps (Android & iOS)"]:::ui
        ROS["ROS Integration"]:::ui
    end

    %% Utility Tools & Examples Subgraph
    subgraph "Utility & Tools"
        UTILS["Utility Tools & Examples"]:::integration
    end

    %% Build & Deployment Subgraph
    subgraph "Build & Deployment"
        BUILD["Build System & CI/CD"]:::build
    end

    %% Connections: Sensor Modules to Core
    CAM --> CORE
    ODO --> CORE
    LIDAR --> CORE
    IMU --> CORE

    %% Connections: Core to other components
    CORE --> DB
    CORE --> DESKTOP
    CORE --> MOBILE
    CORE --> ROS
    CORE --> UTILS

    %% Connections: Build & Deployment supports various components
    BUILD -->|"builds"| CORE
    BUILD -->|"builds"| DESKTOP
    BUILD -->|"builds"| MOBILE
    BUILD -->|"builds"| ROS
    BUILD -->|"builds"| UTILS

    %% Styles classes
    classDef sensors fill:#ffe6e6,stroke:#b30000,stroke-width:2px;
    classDef core fill:#cce6ff,stroke:#003399,stroke-width:2px;
    classDef db fill:#e6ffe6,stroke:#008000,stroke-width:2px;
    classDef ui fill:#e6ffe6,stroke:#006600,stroke-width:2px;
    classDef integration fill:#fff0b3,stroke:#cc7a00,stroke-width:2px;
    classDef build fill:#e6ffff,stroke:#008080,stroke-width:2px;

    %% Click Events for Sensor Modules
    click CAM "https://github.com/introlab/rtabmap/tree/master/corelib/include/rtabmap/core/camera"
    click ODO "https://github.com/introlab/rtabmap/tree/master/corelib/include/rtabmap/core/odometry"
    click LIDAR "https://github.com/introlab/rtabmap/tree/master/corelib/include/rtabmap/core/lidar"
    click IMU "https://github.com/introlab/rtabmap/tree/master/corelib/include/rtabmap/core/IMU"

    %% Click Events for Core SLAM Engine
    click CORE "https://github.com/introlab/rtabmap/tree/master/corelib"

    %% Click Events for Data Storage
    click DB "https://github.com/introlab/rtabmap/blob/master/corelib/include/rtabmap/core/DBDriverSqlite3.h"

    %% Click Events for User Interfaces
    click DESKTOP "https://github.com/introlab/rtabmap/tree/master/guilib/include/rtabmap/gui"
    click MOBILE "https://github.com/introlab/rtabmap/tree/master/app/android"
    click MOBILE "https://github.com/introlab/rtabmap/tree/master/app/ios"
    click ROS "https://github.com/introlab/rtabmap/blob/master/package.xml"
    click ROS "https://github.com/introlab/rtabmap/blob/master/.github/workflows/cmake-ros.yml"

    %% Click Events for Utility Tools & Examples
    click UTILS "https://github.com/introlab/rtabmap/tree/master/tools"

    %% Click Events for Build & Deployment
    click BUILD "https://github.com/introlab/rtabmap/blob/master/CMakeLists.txt"
    click BUILD "https://github.com/introlab/rtabmap/tree/master/docker"
```
