# bchrobotics/trojans2024 architecture

> Architecture diagram of the GitHub repository bchrobotics/trojans2024, 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/bchrobotics/trojans2024
- Repository: https://github.com/bchrobotics/trojans2024

## Overview

##### Main Components
- Robot Control Core: This central module is represented by classes like Main.java, Robot.java, and RobotContainer.java. They serve as the entry point and orchestrate the robot’s behavior.
- Subsystems: Located in src/main/java/frc/robot/subsystems, these include components like the Drivetrain, Elevator, Mechanism, and the specialized MAXSwerveModule. Each subsystem maps directly to a physical part of the robot.
- Commands: Found in src/main/java/frc/robot/commands (e.g., CombinedCommands.java). These encapsulate the actions that the subsystems perform.
- Utility Classes: Under src/main/java/frc/utils, these include helper classes for control algorithms (like BetterPIDController and BetterProfiledPIDController) and hardware device abstractions (e.g., Camera, LEDs, BeamBreak). They provide supportive functionality across the robot’s code.
- Deployment & Autonomous Paths: The directory src/main/deploy (with its nested pathplanner folder) contains files for autonomous routines and path planning. This represents configuration data that defines autonomous movement routines and navigation grids.
- Vendor Dependencies: Managed under vendordeps and referenced in the README (NavX, REVLib, PathplannerLib, photonlib). These represent the external libraries and hardware drivers integrated into the project.
- Build and Configuration Systems: Gradle scripts (build.gradle, settings.gradle, gradle wrapper files) configure project builds and deployments, while configuration files (.Glass, .SysId, .wpilib, etc.) support the development and deployment environments.

##### Relationships and Interactions
- The deployment folder’s autonomous routines and paths are used by the core code (or autonomous commands) to control navigation. Represent these as separate configuration input components which supply path definitions.
- Vendor libraries provide essential support for tasks like sensor fusion (NavX) and advanced drive functionality (PathplannerLib); show these as external modules that interface with both the core and the subsystems.
- External interactions: the connection to the Driver Station and the use of WPILib provides a bridge between the robot hardware and operator input.

##### Architectural Patterns and Principles
- Command-Based Design: Make it clear that the project follows the command-based pattern typical in FRC robot projects. The separation between subsystems and commands should be visually distinct.
- Modularization: The project is split into well-defined packages (robot code, commands, subsystems, utils) which promotes separation of concerns.
- Configuration-Driven Autonomous: The use of deploy folders with path and autonomous files (“.auto” files) indicates that autonomous behavior is configured externally, allowing for on-the-fly adjustments without modifying core code.

## Diagram (Mermaid)

```mermaid
graph TD

    %% External Components
    d1["Driver Station"]:::external

    %% Vendor Dependencies
    v1["Vendor Dependencies"]:::vendor

    %% Build & Configuration
    b1["Build & Config"]:::build

    %% Autonomous & Path Planning Group
    subgraph "Autonomous & Path Planning"
        a1["Autonomous Autos"]:::auto
        a2["Path Configurations"]:::auto
        a3["NavGrid"]:::auto
    end

    %% Utility & Device Abstractions Group
    subgraph "Utility & Devices"
        u1["SwerveUtils"]:::util
        u2["BetterPIDController"]:::util
        u3["BetterProfiledPIDController"]:::util
        u4["BeamBreak"]:::util
        u5["Camera"]:::util
        u6["LEDs"]:::util
    end

    %% Commands Group
    subgraph "Commands"
        c1["CombinedCommands"]:::command
    end

    %% Subsystems Group
    subgraph "Subsystems"
        s1["Drivetrain"]:::subsystem
        s2["Elevator"]:::subsystem
        s3["MAXSwerveModule"]:::subsystem
        s4["Mechanism"]:::subsystem
    end

    %% Robot Control Core Group
    subgraph "Robot Control Core"
        r1["Main"]:::core
        r2["Robot"]:::core
        r3["RobotContainer"]:::core
    end

    %% Connections
    %% Driver Station to Robot Control Core
    d1 -->|"input"| r1

    %% Robot Control Core internal flow
    r1 --> r2
    r2 --> r3

    %% RobotContainer coordinating subsystems and commands
    r3 -->|"init_subsystems"| s1
    r3 -->|"init_subsystems"| s2
    r3 -->|"init_subsystems"| s3
    r3 -->|"init_subsystems"| s4
    r3 -->|"schedule_commands"| c1

    %% Utilities support Subsystems (and indirectly core)
    s1 -->|"sensor/actuator control"| u1
    s2 --> u2
    s3 --> u3
    s4 --> u4
    s1 --> u5
    s2 --> u6

    %% Autonomous & Path Planning influence Robot Control Core
    a1 -->|"auto_select"| r3
    a2 --> r3
    a3 --> a2

    %% Vendor Dependencies integration with Core and Subsystems
    v1 --> r3
    v1 --> s1
    v1 --> s2
    v1 --> s3
    v1 --> s4

    %% Build & Configuration supports the project
    b1 --> r3

    %% Commands interact with Subsystems
    c1 -->|"execute"| s1
    c1 --> s2
    c1 --> s3
    c1 --> s4

    %% Click Events for Robot Control Core
    click r1 "https://github.com/bchrobotics/trojans2024/blob/dev/src/main/java/frc/robot/Main.java"
    click r2 "https://github.com/bchrobotics/trojans2024/blob/dev/src/main/java/frc/robot/Robot.java"
    click r3 "https://github.com/bchrobotics/trojans2024/blob/dev/src/main/java/frc/robot/RobotContainer.java"

    %% Click Events for Subsystems (directory mapping)
    click s1 "https://github.com/bchrobotics/trojans2024/tree/dev/src/main/java/frc/robot/subsystems"
    click s2 "https://github.com/bchrobotics/trojans2024/tree/dev/src/main/java/frc/robot/subsystems"
    click s3 "https://github.com/bchrobotics/trojans2024/tree/dev/src/main/java/frc/robot/subsystems"
    click s4 "https://github.com/bchrobotics/trojans2024/tree/dev/src/main/java/frc/robot/subsystems"

    %% Click Event for Commands
    click c1 "https://github.com/bchrobotics/trojans2024/blob/dev/src/main/java/frc/robot/commands/CombinedCommands.java"

    %% Click Events for Utilities & Devices
    click u1 "https://github.com/bchrobotics/trojans2024/blob/dev/src/main/java/frc/utils/SwerveUtils.java"
    click u2 "https://github.com/bchrobotics/trojans2024/blob/dev/src/main/java/frc/utils/controllers/BetterPIDController.java"
    click u3 "https://github.com/bchrobotics/trojans2024/blob/dev/src/main/java/frc/utils/controllers/BetterProfiledPIDController.java"
    click u4 "https://github.com/bchrobotics/trojans2024/blob/dev/src/main/java/frc/utils/devices/BeamBreak.java"
    click u5 "https://github.com/bchrobotics/trojans2024/blob/dev/src/main/java/frc/utils/devices/Camera.java"
    click u6 "https://github.com/bchrobotics/trojans2024/blob/dev/src/main/java/frc/utils/devices/LEDs.java"

    %% Click Events for Autonomous & Path Planning
    click a1 "https://github.com/bchrobotics/trojans2024/tree/dev/src/main/deploy/pathplanner/autos"
    click a2 "https://github.com/bchrobotics/trojans2024/tree/dev/src/main/deploy/pathplanner/paths"
    click a3 "https://github.com/bchrobotics/trojans2024/blob/dev/src/main/deploy/pathplanner/navgrid.json"

    %% Click Event for Vendor Dependencies
    click v1 "https://github.com/bchrobotics/trojans2024/tree/dev/vendordeps"

    %% Click Event for Build & Config (using a representative file)
    click b1 "https://github.com/bchrobotics/trojans2024/blob/dev/build.gradle"

    %% Styles
    classDef core fill:#FFCCCC,stroke:#333,stroke-width:2px;
    classDef subsystem fill:#CCFFCC,stroke:#333,stroke-width:2px;
    classDef command fill:#CCCCFF,stroke:#333,stroke-width:2px;
    classDef util fill:#FFFFCC,stroke:#333,stroke-width:2px;
    classDef auto fill:#E6CCFF,stroke:#333,stroke-width:2px;
    classDef vendor fill:#FFDAB9,stroke:#333,stroke-width:2px;
    classDef build fill:#CCFFFF,stroke:#333,stroke-width:2px;
    classDef external fill:#E0E0E0,stroke:#333,stroke-width:2px;
```
