How rodolfosouzamoraes/swerve-mk4i-drivetrain-frc works
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: SwerveSubsystem.java Swerve subsystem · RobotContainer.java Robot container · SwerveModule.java Swerve module · Robot.java Robot lifecycle
Components 14
Robot lifecycle
- Robot entry point
src/main/java/frc/robot/Main.java - Robot lifecycle
src/main/java/frc/robot/Robot.java
Driver control
- Robot container
src/main/java/frc/robot/RobotContainer.java
Swerve drivetrain
- Swerve subsystem
src/main/java/frc/robot/subsystems/SwerveSubsystem.java - Swerve module
src/main/java/frc/robot/subsystems/SwerveModule.java - Swerve configuration
src/main/java/frc/robot/Constants.java - Pose odometry
src/main/java/frc/robot/subsystems/SwerveSubsystem.java - Pigeon 2 IMU
- CANcoder sensors
- SparkMax motors
Example commands
- Example auto factory
src/main/java/frc/robot/commands/Autos.java - Example command
src/main/java/frc/robot/commands/ExampleCommand.java - Example subsystem
src/main/java/frc/robot/subsystems/ExampleSubsystem.java
Other components
- Xbox driver
Connections 18
- Robot entry point → Robot lifecycle: starts
src/main/java/frc/robot/Main.java - Robot lifecycle → Robot container: constructs
src/main/java/frc/robot/Robot.java - Robot lifecycle → Robot container: uses commands
src/main/java/frc/robot/Robot.java - Robot container → Swerve subsystem: constructs
src/main/java/frc/robot/RobotContainer.java - Xbox driver → Robot container: provides input
src/main/java/frc/robot/RobotContainer.java - Robot container → Swerve subsystem: dispatches drive
src/main/java/frc/robot/RobotContainer.java - Robot container → Swerve subsystem: zeros heading
src/main/java/frc/robot/RobotContainer.java - Swerve subsystem → Swerve module: sets module states
src/main/java/frc/robot/subsystems/SwerveSubsystem.java - Swerve subsystem → Swerve configuration: uses kinematics
src/main/java/frc/robot/subsystems/SwerveSubsystem.java - Swerve module → Swerve configuration: uses conversions
src/main/java/frc/robot/subsystems/SwerveModule.java - Swerve module → SparkMax motors: sets motor targets
src/main/java/frc/robot/subsystems/SwerveModule.java - Swerve module → CANcoder sensors: reads absolute position
src/main/java/frc/robot/subsystems/SwerveModule.java - Swerve subsystem → Pigeon 2 IMU: reads heading
src/main/java/frc/robot/subsystems/SwerveSubsystem.java - Swerve subsystem → Pose odometry: updates pose
src/main/java/frc/robot/subsystems/SwerveSubsystem.java - Pose odometry → Swerve module: reads positions
src/main/java/frc/robot/subsystems/SwerveSubsystem.java - Example auto factory → Example subsystem: builds sequence
src/main/java/frc/robot/commands/Autos.java - Example auto factory → Example command: builds sequence
src/main/java/frc/robot/commands/Autos.java - Example command → Example subsystem: requires
src/main/java/frc/robot/commands/ExampleCommand.java