# team-micras/micrasfirmware architecture

> Architecture diagram of the GitHub repository team-micras/micrasfirmware, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/team-micras/micrasfirmware
- Repository: https://github.com/team-micras/micrasfirmware

## Overview

##### Project Type Analysis
This is an embedded systems firmware project for a micromouse robot, built with C++ using STM32 microcontroller. The project follows a modular architecture with clear separation of concerns.

##### Main Components

A. Hardware Layer (Bottom Level):
- STM32 Microcontroller
- Physical Components (Motors, Sensors, LEDs, etc.)

B. HAL Layer (micras_hal):
- ADC/DMA Controllers
- GPIO Interface
- Timer Management
- PWM Controllers
- SPI Communication
- Flash Memory Interface

C. Proxy Layer (micras_proxy):
- Hardware Component Abstractions:
- Motors/Locomotion
- Sensors (IMU, Wall, Torque)
- User Interface (LED, Button, Display)
- Power Management (Battery, Fan)

D. Core Layer (micras_core):
- Utility Functions
- Data Types
- Signal Processing (Butterworth Filter)

E. Navigation Layer (micras_nav):
- Maze Mapping
- Path Planning
- Motion Control
- State Management
- PID Controllers

**[Physical Hardware Layer]**
- ↑↓
**[STM32 HAL Layer (micras_hal)]**
- ↑↓
**[Hardware Proxy Layer (micras_proxy)]**
- ↑↓
**[Core Utilities (micras_core)]**
- ↑↓
**[Navigation System (micras_nav)]**
- ↑↓
**[Main Controller]**

##### Implementation Notes

- Maintain consistent styling
- Brief descriptions for each major component
- Version control integration points

##### Key Relationships to Highlight

- Hardware abstraction layers
- Sensor data flow
- Motion control pipeline
- Navigation algorithm integration
- State management system
- Testing infrastructure

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style definitions
    classDef hardware fill:#D3D3D3
    classDef hal fill:#B0C4DE
    classDef proxy fill:#90EE90
    classDef core fill:#FFE4B5
    classDef nav fill:#FFA07A
    classDef main fill:#FF6B6B

    %% Navigation Layer Detailed Breakdown
    subgraph Navigation
        Mapping["Maze Mapping"]
        PathPlanning["Path Planning"]
        MotionControl["Motion Control"]
        StateMgmt["State Management"]
        PIDControl["PID Controllers"]
        
        subgraph MazeMapping
            GridMap["Grid Map"]
            WallDetection["Wall Detection"]
            CellUpdate["Cell Update Logic"]
        end
        
        subgraph PathPlanningDetail
            FloodFill["Flood Fill Algorithm"]
            ShortestPath["Shortest Path"]
            PathOptimization["Path Optimization"]
        end
        
        subgraph MotionControlDetail
            Trajectory["Trajectory Planning"]
            SpeedProfile["Speed Profiling"]
            TurnControl["Turn Control"]
        end
        
        subgraph StateManagement
            RobotStates["Robot States"]
            StateTransitions["State Transitions"]
            EventHandling["Event Handling"]
        end
        
        subgraph PIDControllers
            SpeedPID["Speed PID"]
            AnglePID["Angle PID"]
            WallFollowPID["Wall Follow PID"]
        end
    end
    
    %% Navigation Internal Connections
    Mapping --> GridMap
    Mapping --> WallDetection
    Mapping --> CellUpdate
    
    PathPlanning --> FloodFill
    PathPlanning --> ShortestPath
    PathPlanning --> PathOptimization
    
    MotionControl --> Trajectory
    MotionControl --> SpeedProfile
    MotionControl --> TurnControl
    
    StateMgmt --> RobotStates
    StateMgmt --> StateTransitions
    StateMgmt --> EventHandling
    
    PIDControl --> SpeedPID
    PIDControl --> AnglePID
    PIDControl --> WallFollowPID

    class Mapping,PathPlanning,MotionControl,StateMgmt,PIDControl nav
    class GridMap,WallDetection,CellUpdate,FloodFill,ShortestPath,PathOptimization nav
    class Trajectory,SpeedProfile,TurnControl,RobotStates,StateTransitions,EventHandling nav
    class SpeedPID,AnglePID,WallFollowPID nav

    click Mapping "https://github.com/Team-Micras/MicrasFirmware/blob/develop/micras_nav/include/micras/nav/mapping.hpp"
    click PathPlanning "https://github.com/Team-Micras/MicrasFirmware/blob/develop/micras_nav/include/micras/nav/maze.hpp"
    click MotionControl "https://github.com/Team-Micras/MicrasFirmware/tree/develop/micras_nav/include/micras/nav"
    click StateMgmt "https://github.com/Team-Micras/MicrasFirmware/blob/develop/micras_nav/include/micras/nav/state.hpp"
    click PIDControl "https://github.com/Team-Micras/MicrasFirmware/blob/develop/micras_nav/include/micras/nav/pid_controller.hpp"
```
