# stop16/dmu-nurinarae-smartrobot-2023 architecture

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

- Interactive diagram: https://gitdiagram.com/stop16/dmu-nurinarae-smartrobot-2023
- Repository: https://github.com/stop16/dmu-nurinarae-smartrobot-2023

## Overview

##### Project Type and Purpose
- Project Type: A hybrid system mixing high-level control/algorithms (written in Python) with low-level microcontroller firmware (Arduino .ino files). It covers both algorithm development (decision making, sensor processing) and direct hardware control (motor control, PWM, servo tests).

##### File Structure
- Top-Level Files (e.g., Algorithm.py, Algorithm_from_pi.py, Color_detection_v2.py, cam_test.py, etc.) indicate modules that process sensor data, run decision algorithms, and perhaps perform testing.
- Directories:
- Firmware_for_A, Firmware_for_B, Servotest – These folders contain Arduino sketches (firmware) for different microcontrollers or components of the robot.
- Test and Utility Files (e.g., color_detection_test.py, line_trace22.ino, pwm_test.py, serialtest.py, tuning.py) help verify proper functioning of both algorithm modules and hardware interface routines.
- The file tree suggests a clear separation between high-level algorithmic control (Python) and low-level hardware actuation (Arduino firmware).

##### README for Additional Insights
- No extra sections about configuration or detailed architecture are provided, so the file tree’s organization is our best guide.

##### Main Components
a. High-Level Control (Python Modules):
- Algorithm Modules: "Algorithm.py" and "Algorithm_from_pi.py" – these likely implement navigation or behavior logic.
- Test/Utility Scripts: "pwm_test.py", "serialtest.py", and "tuning.py" – Scripts for testing and fine-tuning various hardware parameters.
b. Embedded Control (Firmware / Arduino Code):
- Microcontroller Firmware:
- "Firmware_for_A/Firmware_for_A.ino" and "Firmware_for_B/Firmware_for_B.ino" – distinct firmware images for possibly different microcontrollers.
- "Servotest/Servotest.ino" – dedicated testing for servos.
- "line_trace22.ino" – likely contains code for line-following functionality.
c. Communication Mechanisms:
- There is a strong suggestion of communication links (e.g., via serial – reinforced by "serialtest.py") between the high-level Python control running on a central processor (or Raspberry Pi) and the microcontrollers running Arduino firmware.
d. Additional Elements:

a. Start by mapping out each major subsystem:
- A. Central Processing Unit (CPU):
- B. Embedded Controllers:
- C. Communication Interfaces:
- Insert a “Communication Layer” (e.g., Serial Communication) between the CPU and Embedded Controllers, denoting the flow of commands and sensor data.
- D. Sensors & Actuators (Physical Interfaces):
- Blocks for Sensors (camera, line sensor) and Actuators (motors, servos) to show that the firmware interacts with physical hardware.

b. Relationships and Interactions:
- From the High-Level Control block to the Communication Interface and then to each Embedded Controller.
- That testing/diagnostic scripts (e.g., serialtest, pwm_test) may interact with both the high-level system and hardware, serving as validation tools.

c. Design Principles and Technologies:
- Modularity: Separate high-level decision-making from low-level actuator control.
- Communication: Reliance on serial communication (as indicated by the test scripts) between different system components.
- Use of Familiar frameworks and tools: Python for algorithms; Arduino IDE environment for firmware development.
- Testing and Tuning: Indicate that there are dedicated testing modules for tuning performance (which are crucial in robotics competitions).

##### Specific Elements
- From sensors to processing.
- From the CPU to the microcontrollers.
- Feedback from the hardware back to the CPU.
- Another for embedded firmware.
- Additional styling for external hardware components.

##### Final Reminders
- Every major file group is represented, so reviewers and team members can quickly understand the relationship between software, firmware, and hardware.
- Keep annotations brief but descriptive enough so that each component’s role in the overall system is clear.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% High-Level Control (Python)
    subgraph "High-Level Control (Python)"
        subgraph "Algorithm Modules"
            alg1["Algorithm.py"]:::python
            alg2["Algorithm_from_pi.py"]:::python
        end
        subgraph "Sensor Processing Modules"
            s1["Color_detection_v2.py"]:::python
            s2["color_detection.py"]:::python
            s3["cam_test.py"]:::python
            s4["color_detection_test.py"]:::python
        end
        subgraph "Test & Tuning Utilities"
            t1["pwm_test.py"]:::python
            t2["serialtest.py"]:::python
            t3["tuning.py"]:::python
        end
        CPU["Central Processor"]:::python
    end

    %% Communication Layer
    Comm["Serial Communication"]:::comm

    %% Embedded Controllers (Firmware)
    subgraph "Embedded Controllers (Firmware)"
        e1["Firmware Controller A"]:::firmware
        e2["Firmware Controller B"]:::firmware
        e3["Servo Test Firmware"]:::firmware
        e4["Line Tracking Firmware"]:::firmware
    end

    %% Physical Interfaces (Sensors & Actuators)
    subgraph "Physical Interfaces"
        Sensors["Sensors (Camera,Line Sensor)"]:::hardware
        Actuators["Actuators (Motors,Servos)"]:::hardware
    end

    %% Connections
    Sensors -->|"feeds"| CPU
    CPU <-->|"serial"| Comm
    Comm <-->|"serial"| e1
    Comm <-->|"serial"| e2
    Comm <-->|"serial"| e3
    Comm <-->|"serial"| e4
    e1 -->|"controls"| Actuators
    e2 -->|"controls"| Actuators
    e3 -->|"controls"| Actuators
    e4 -->|"controls"| Actuators

    %% Click Events for High-Level Python Modules
    click alg1 "https://github.com/stop16/dmu-nurinarae-smartrobot-2023/blob/main/Algorithm.py"
    click alg2 "https://github.com/stop16/dmu-nurinarae-smartrobot-2023/blob/main/Algorithm_from_pi.py"
    click s1 "https://github.com/stop16/dmu-nurinarae-smartrobot-2023/blob/main/Color_detection_v2.py"
    click s2 "https://github.com/stop16/dmu-nurinarae-smartrobot-2023/blob/main/color_detection.py"
    click s3 "https://github.com/stop16/dmu-nurinarae-smartrobot-2023/blob/main/cam_test.py"
    click s4 "https://github.com/stop16/dmu-nurinarae-smartrobot-2023/blob/main/color_detection_test.py"
    click t1 "https://github.com/stop16/dmu-nurinarae-smartrobot-2023/blob/main/pwm_test.py"
    click t2 "https://github.com/stop16/dmu-nurinarae-smartrobot-2023/blob/main/serialtest.py"
    click t3 "https://github.com/stop16/dmu-nurinarae-smartrobot-2023/blob/main/tuning.py"

    %% Click Events for Embedded Firmware
    click e1 "https://github.com/stop16/dmu-nurinarae-smartrobot-2023/blob/main/Firmware_for_A/Firmware_for_A.ino"
    click e2 "https://github.com/stop16/dmu-nurinarae-smartrobot-2023/blob/main/Firmware_for_B/Firmware_for_B.ino"
    click e3 "https://github.com/stop16/dmu-nurinarae-smartrobot-2023/blob/main/Servotest/Servotest.ino"
    click e4 "https://github.com/stop16/dmu-nurinarae-smartrobot-2023/blob/main/line_trace22.ino"

    %% Styles
    classDef python fill:#bbf,stroke:#333,stroke-width:2px;
    classDef firmware fill:#cfc,stroke:#333,stroke-width:2px;
    classDef comm fill:#ffc,stroke:#333,stroke-width:2px;
    classDef hardware fill:#fed,stroke:#333,stroke-width:2px;
```
