# rodolfosouzamoraes/swerve-mk4i-drivetrain-frc architecture

> Architecture diagram of the GitHub repository rodolfosouzamoraes/swerve-mk4i-drivetrain-frc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc
- Repository: https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc

## Overview

This is an FRC command-based robot application for Xbox-operated, field-oriented swerve driving. The primary workflow is controller input through RobotContainer into the swerve drivetrain, which converts chassis motion into module setpoints for SparkMax motors; the Pigeon and wheel sensors provide heading and position for odometry. Robot runs the WPILib command scheduler. The repository also retains WPILib example command/subsystem code; autonomous scheduling is commented out in Robot. Unsampled details are represented only where the README or source index supports them.

Main entry points: [`src/main/java/frc/robot/subsystems/SwerveSubsystem.java`](https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/subsystems/SwerveSubsystem.java) (Swerve subsystem), [`src/main/java/frc/robot/RobotContainer.java`](https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/RobotContainer.java) (Robot container), [`src/main/java/frc/robot/subsystems/SwerveModule.java`](https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/subsystems/SwerveModule.java) (Swerve module), [`src/main/java/frc/robot/Robot.java`](https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/Robot.java) (Robot lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lifecycle["Robot lifecycle"]
  node_main["Robot entry point<br/>[Main.java]"]
  node_robot["Robot lifecycle<br/>[Robot.java]"]
end

subgraph group_control["Driver control"]
  node_container["Robot container"]
end

subgraph group_drive["Swerve drivetrain"]
  node_swerve["Swerve subsystem"]
  node_module["Swerve module<br/>[SwerveModule.java]"]
  node_constants["Swerve configuration<br/>[Constants.java]"]
  node_odometry["Pose odometry"]
  node_pigeon["Pigeon 2 IMU"]
  node_cancoder["CANcoder sensors"]
  node_spark["SparkMax motors"]
end

subgraph group_examples["Example commands"]
  node_autos["Example auto factory<br/>[Autos.java]"]
  node_examplecommand["Example command"]
  node_examplesubsystem["Example subsystem"]
end

node_driver(("Xbox driver"))

node_main -->|"starts"| node_robot
node_robot -->|"constructs"| node_container
node_robot -->|"uses commands"| node_container
node_container -->|"constructs"| node_swerve
node_driver -->|"provides input"| node_container
node_container -->|"dispatches drive"| node_swerve
node_container -->|"zeros heading"| node_swerve
node_swerve -->|"sets module states"| node_module
node_swerve -->|"uses kinematics"| node_constants
node_module -->|"uses conversions"| node_constants
node_module -->|"sets motor targets"| node_spark
node_module -->|"reads absolute position"| node_cancoder
node_swerve -->|"reads heading"| node_pigeon
node_swerve -->|"updates pose"| node_odometry
node_odometry -->|"reads positions"| node_module
node_autos -->|"builds sequence"| node_examplesubsystem
node_autos -->|"builds sequence"| node_examplecommand
node_examplecommand -->|"requires"| node_examplesubsystem

click node_main "https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/Main.java"
click node_robot "https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/Robot.java"
click node_container "https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/RobotContainer.java"
click node_swerve "https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/subsystems/SwerveSubsystem.java"
click node_module "https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/subsystems/SwerveModule.java"
click node_constants "https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/Constants.java"
click node_odometry "https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/subsystems/SwerveSubsystem.java"
click node_autos "https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/commands/Autos.java"
click node_examplecommand "https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/commands/ExampleCommand.java"
click node_examplesubsystem "https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/subsystems/ExampleSubsystem.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_robot toneBlue
class node_container toneAmber
class node_swerve,node_module,node_constants,node_odometry,node_pigeon,node_cancoder,node_spark toneMint
class node_autos,node_examplecommand,node_examplesubsystem toneRose
class node_driver toneIndigo
```

## Components

### Robot lifecycle

- [Robot entry point](https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/Main.java): `src/main/java/frc/robot/Main.java`
- [Robot lifecycle](https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/Robot.java): `src/main/java/frc/robot/Robot.java`

### Driver control

- [Robot container](https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/RobotContainer.java): `src/main/java/frc/robot/RobotContainer.java`

### Swerve drivetrain

- [Swerve subsystem](https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/subsystems/SwerveSubsystem.java): `src/main/java/frc/robot/subsystems/SwerveSubsystem.java`
- [Swerve module](https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/subsystems/SwerveModule.java): `src/main/java/frc/robot/subsystems/SwerveModule.java`
- [Swerve configuration](https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/Constants.java): `src/main/java/frc/robot/Constants.java`
- [Pose odometry](https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/subsystems/SwerveSubsystem.java): `src/main/java/frc/robot/subsystems/SwerveSubsystem.java`
- **Pigeon 2 IMU**
- **CANcoder sensors**
- **SparkMax motors**

### Example commands

- [Example auto factory](https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/commands/Autos.java): `src/main/java/frc/robot/commands/Autos.java`
- [Example command](https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/commands/ExampleCommand.java): `src/main/java/frc/robot/commands/ExampleCommand.java`
- [Example subsystem](https://github.com/rodolfosouzamoraes/swerve-mk4i-drivetrain-frc/blob/main/src/main/java/frc/robot/subsystems/ExampleSubsystem.java): `src/main/java/frc/robot/subsystems/ExampleSubsystem.java`

### Other components

- **Xbox driver**

## Connections

- Robot entry point → Robot lifecycle: starts (evidence: `src/main/java/frc/robot/Main.java`)
- Robot lifecycle → Robot container: constructs (evidence: `src/main/java/frc/robot/Robot.java`)
- Robot lifecycle → Robot container: uses commands (evidence: `src/main/java/frc/robot/Robot.java`)
- Robot container → Swerve subsystem: constructs (evidence: `src/main/java/frc/robot/RobotContainer.java`)
- Xbox driver → Robot container: provides input (evidence: `src/main/java/frc/robot/RobotContainer.java`)
- Robot container → Swerve subsystem: dispatches drive (evidence: `src/main/java/frc/robot/RobotContainer.java`)
- Robot container → Swerve subsystem: zeros heading (evidence: `src/main/java/frc/robot/RobotContainer.java`)
- Swerve subsystem → Swerve module: sets module states (evidence: `src/main/java/frc/robot/subsystems/SwerveSubsystem.java`)
- Swerve subsystem → Swerve configuration: uses kinematics (evidence: `src/main/java/frc/robot/subsystems/SwerveSubsystem.java`)
- Swerve module → Swerve configuration: uses conversions (evidence: `src/main/java/frc/robot/subsystems/SwerveModule.java`)
- Swerve module → SparkMax motors: sets motor targets (evidence: `src/main/java/frc/robot/subsystems/SwerveModule.java`)
- Swerve module → CANcoder sensors: reads absolute position (evidence: `src/main/java/frc/robot/subsystems/SwerveModule.java`)
- Swerve subsystem → Pigeon 2 IMU: reads heading (evidence: `src/main/java/frc/robot/subsystems/SwerveSubsystem.java`)
- Swerve subsystem → Pose odometry: updates pose (evidence: `src/main/java/frc/robot/subsystems/SwerveSubsystem.java`)
- Pose odometry → Swerve module: reads positions (evidence: `src/main/java/frc/robot/subsystems/SwerveSubsystem.java`)
- Example auto factory → Example subsystem: builds sequence (evidence: `src/main/java/frc/robot/commands/Autos.java`)
- Example auto factory → Example command: builds sequence (evidence: `src/main/java/frc/robot/commands/Autos.java`)
- Example command → Example subsystem: requires (evidence: `src/main/java/frc/robot/commands/ExampleCommand.java`)
