# kmg3821/slam_pjt architecture

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

- Interactive diagram: https://gitdiagram.com/kmg3821/slam_pjt
- Repository: https://github.com/kmg3821/slam_pjt

## Overview

##### Main Components
- Remote SLAM Engine:
- Represented by the “slam/mono” directory. It contains key SLAM source files (slam.cc, slam_json.cc, etc.) and likely performs the heavy lifting for environment mapping.
- Use elements like “ORB SLAM3” and “Occupancy Grid Generation” as labels.
- Controller Server:
- Split into “controller-server/back” (Node.js backend) and “controller-server/front” (client-side frontend with static HTML/CSS/JS).
- This component acts as the bridge between the user interface and other system parts.
- Raspberry Pi Subsystem:
- Contains two distinct parts:
- “raspberrypi/mono/send” (and variants): likely used for sending sensor or control data (implemented in C++ with additional variants like send_old).
- “raspberrypi/motor”: Python scripts for motor control (such as Raspi_I2C.py, Raspi_MotorHAT.py, and PWM driver) and configuration.
- Calibration & Configuration:
- “calibration” directory houses camera calibration (cam_intrinsic.txt) used by the SLAM system.
- “config” directory holds configuration stubs and related files (e.g., config.js) to parameterize system components.

##### Relationships and Data Flows
- Data Flow from the Remote SLAM Engine to the Controller Server:
- Communication Between the Controller Server and Raspberry Pi:
- The controller server likely sends control commands (e.g., motor control signals) to the Raspberry Pi while also receiving status updates.
- Receiving (raspberrypi/mono/receive variants in tests) and sending (raspberrypi/mono/send variants) functionalities are hinted at by corresponding test directories.
- Feedback Loops and Control Instructions:
- External or Deployment Details:
- Optionally, note that the remote SLAM engine “runs on a remote computer,” indicating network communication. Show network boundaries or labels such as “Remote Host” or “Cloud/Remote SLAM server.”

##### Architectural Patterns/Design Principles
- Separation of Concerns:
- User interface (frontend), business logic (backend), real-time motor control (Raspberry Pi), and intensive mapping (SLAM) are separated.
- Modular Components:
- Each directory (controller-server, raspberrypi, slam) encapsulates distinct functionality.
- Use of Configuration and Calibration:
- External config files facilitate environment-specific adjustments without altering core algorithms.

##### Relevant Technologies & Frameworks
- For the Controller Server: Node.js (backend and frontend, with package.json, index.js, etc.).
- For the SLAM Engine: C/C++ based SLAM (possibly ORB SLAM3 or a variant), with usage of calibration files.
- For the Raspberry Pi: Python for motor control (using libraries like MotorHAT, PWM drivers) and C++ for sensor data sending.
- Build/Test Tools: CMake for building parts of the test modules, Makefiles in the SLAM and Raspberry Pi sections, and potential version control (.gitignore files present throughout).

##### Final Touches
- Extra details where applicable: for examples, mention “orb slam3” in the SLAM component and “rc car” as the overall system objective.
- Incorporate deployment-related labels if transformations (e.g., compilation with Makefile, deployment via package managers) are relevant.
- Do not overcomplicate—but capture as many essential architectural elements as possible to serve as accurate documentation for implementation or future development.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Remote Host
    subgraph "Remote Host"
        RS["Remote SLAM Engine (ORB SLAM3, Occupancy Grid)"]:::slam
    end

    %% Controller Server
    subgraph "Controller Server"
        CSB["Controller Server (Backend - Node.js)"]:::backend
        CSF["Controller Server (Frontend - Static HTML/CSS/JS)"]:::frontend
    end

    %% Raspberry Pi Subsystem
    subgraph "Raspberry Pi Subsystem"
        RPiMC["Raspberry Pi Mono Communication (Send Data, C++)"]:::pi
        RPiMotor["Raspberry Pi Motor Control (Python)"]:::pi
    end

    %% Calibration and Configuration
    CAL["Calibration Data"]:::calibration
    CFG["Configuration Files"]:::config

    %% Data Flows
    CAL -->|"calibration_data"| RS
    CFG -->|"config_param"| RS
    CFG -->|"config_param"| RPiMotor

    RS -->|"mapping_output"| CSB
    CSF -->|"UI_commands"| CSB
    CSB -->|"control_commands"| RPiMC
    CSB -->|"motor_instructions"| RPiMotor
    RPiMC -->|"sensor_data_feedback"| CSB
    RPiMotor -->|"telemetry_feedback"| CSB
    CSB -->|"status_updates"| CSF

    %% Click Events
    click RS "https://github.com/kmg3821/slam_pjt/tree/master/slam/mono"
    click CSB "https://github.com/kmg3821/slam_pjt/tree/master/controller-server/back"
    click CSF "https://github.com/kmg3821/slam_pjt/tree/master/controller-server/front"
    click RPiMC "https://github.com/kmg3821/slam_pjt/tree/master/raspberrypi/mono/send"
    click RPiMotor "https://github.com/kmg3821/slam_pjt/tree/master/raspberrypi/motor"
    click CAL "https://github.com/kmg3821/slam_pjt/blob/master/calibration/camera/cam_intrinsic.txt"
    click CFG "https://github.com/kmg3821/slam_pjt/tree/master/config"

    %% Styles
    classDef slam fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef backend fill:#ccffcc,stroke:#006600,stroke-width:2px;
    classDef frontend fill:#ccffff,stroke:#006666,stroke-width:2px;
    classDef pi fill:#ffffcc,stroke:#666600,stroke-width:2px;
    classDef config fill:#e0e0e0,stroke:#999999,stroke-width:2px;
    classDef calibration fill:#e6ccff,stroke:#660099,stroke-width:2px;
```
