Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/robototes/REBUILT2026/llms.txt

Use this file to discover all available pages before exploring further.

CompTunerConstants and AlphaTunerConstants are generated by Phoenix 6 Tuner X and define swerve module geometry, PID gains, and maximum speeds for each physical robot. The correct file is selected at runtime by Subsystems.java based on RobotType.TYPE.
These files are generated from a tuner-swerve-project.json that is checked into the repository. To regenerate them — for example after re-running sysid or changing hardware — open that JSON in Tuner X’s Swerve Project Generator and export the updated Java files. Do not manually edit the class bodies unless you know exactly which downstream code consumes each constant.

Key constants at a glance

ConstantCompetitionAlphaDescription
kSpeedAt12Volts5.30 m/s5.48 m/sTheoretical free speed at 12 V; used as MaxSpeed throughout drive code
kCANBus"Drivebase""Drivebase"CAN bus name for all swerve devices
kWheelRadius1.924 in1.84 inEffective wheel radius (used for odometry and characterization)
kDriveGearRatio5.357…5.357…Drive motor rotations per wheel rotation
kSteerGearRatio18.7518.75Steer motor rotations per azimuth rotation
kCoupleRatio3.1253.125Drive motor turns per azimuth rotation (coupling compensation)
kSlipCurrent80 A120 AStator current at which wheels begin to slip
kPigeonId1010Pigeon 2 CAN ID

PID and feedforward gains

Steer gains (Slot 0)

GainCompetitionAlphaNotes
kP100100Position proportional
kI00
kD0.50.5
kS0.10.1Static friction feedforward (V)
kV1.792.33Velocity feedforward (V/RPS) — differs between robots
kA00

Drive gains (Slot 0)

GainCompetitionAlphaNotes
kP0.10.1Velocity proportional
kI00
kD00
kS00
kV0.1240.124Velocity feedforward (V/RPS)
Both steer and drive use ClosedLoopOutputType.Voltage.

Module positions

Competition bot

Module positions are measured from the robot center in inches, then converted to a Distance at compile time.
ModuleX (in)Y (in)Drive IDSteer IDEncoder ID
Front Left+9.375+12.375123
Front Right+9.375−12.375456
Back Left−9.375+12.375105012
Back Right−9.375−12.375789

Alpha bot

ModuleX (in)Y (in)Drive IDSteer IDEncoder ID
Front Left+12.375+10.5123
Front Right+12.375−10.5456
Back Left−12.375+10.5789
Back Right−12.375−10.5101112

createDrivetrain() factory method

Each tuner constants class exposes a static factory that constructs the CommandSwerveDrivetrain with all four module constants pre-populated. Subsystems.java calls the appropriate factory depending on robot type:
// Subsystems.java
drivebaseSubsystem =
    (RobotType.TYPE == RobotTypesEnum.ALPHA)
        ? AlphaTunerConstants.createDrivetrain()
        : CompTunerConstants.createDrivetrain();
The factory itself:
// CompTunerConstants.java
public static CommandSwerveDrivetrain createDrivetrain() {
  return new CommandSwerveDrivetrain(
      DrivetrainConstants, FrontLeft, FrontRight, BackLeft, BackRight);
}

Wheel radius characterization

WheelRadiusCharacterization is a utility Command that spins the robot in place while measuring gyro rotation and wheel encoder deltas, then calculates the effective wheel radius:
wheelRadius = (gyroDelta × driveBaseRadius) / wheelDelta
The result is logged via DataLogManager at command end. To run it, hold Y on the launcherTuningController (port assigned in Controls.java):
// Controls.java
connected(launcherTuningController)
    .and(launcherTuningController.y())
    .whileTrue(
        WheelRadiusCharacterization.wheelRadiusCharacterizationCommand(s.drivebaseSubsystem));
The drive-base radius used in the calculation is computed automatically from the module LocationX/LocationY values in CompTunerConstants:
public static final double DRIVE_BASE_RADIUS =
    Math.max(
        Math.max(
            Math.hypot(CompTunerConstants.FrontLeft.LocationX,  CompTunerConstants.FrontLeft.LocationY),
            Math.hypot(CompTunerConstants.FrontRight.LocationX, CompTunerConstants.FrontRight.LocationY)),
        Math.max(
            Math.hypot(CompTunerConstants.BackLeft.LocationX,   CompTunerConstants.BackLeft.LocationY),
            Math.hypot(CompTunerConstants.BackRight.LocationX,  CompTunerConstants.BackRight.LocationY)));
After running characterization, update kWheelRadius in the appropriate tuner constants file with the measured value, then redeploy.
Do not hand-edit kSpeedAt12Volts. This constant is passed directly to SwerveModuleConstantsFactory and is used as MaxSpeed throughout the drive and auto code. Changing it without re-characterizing will cause path following speeds to be scaled incorrectly.

Build docs developers (and LLMs) love