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
| Constant | Competition | Alpha | Description |
|---|
kSpeedAt12Volts | 5.30 m/s | 5.48 m/s | Theoretical free speed at 12 V; used as MaxSpeed throughout drive code |
kCANBus | "Drivebase" | "Drivebase" | CAN bus name for all swerve devices |
kWheelRadius | 1.924 in | 1.84 in | Effective wheel radius (used for odometry and characterization) |
kDriveGearRatio | 5.357… | 5.357… | Drive motor rotations per wheel rotation |
kSteerGearRatio | 18.75 | 18.75 | Steer motor rotations per azimuth rotation |
kCoupleRatio | 3.125 | 3.125 | Drive motor turns per azimuth rotation (coupling compensation) |
kSlipCurrent | 80 A | 120 A | Stator current at which wheels begin to slip |
kPigeonId | 10 | 10 | Pigeon 2 CAN ID |
PID and feedforward gains
Steer gains (Slot 0)
| Gain | Competition | Alpha | Notes |
|---|
| kP | 100 | 100 | Position proportional |
| kI | 0 | 0 | |
| kD | 0.5 | 0.5 | |
| kS | 0.1 | 0.1 | Static friction feedforward (V) |
| kV | 1.79 | 2.33 | Velocity feedforward (V/RPS) — differs between robots |
| kA | 0 | 0 | |
Drive gains (Slot 0)
| Gain | Competition | Alpha | Notes |
|---|
| kP | 0.1 | 0.1 | Velocity proportional |
| kI | 0 | 0 | |
| kD | 0 | 0 | |
| kS | 0 | 0 | |
| kV | 0.124 | 0.124 | Velocity 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.
| Module | X (in) | Y (in) | Drive ID | Steer ID | Encoder ID |
|---|
| Front Left | +9.375 | +12.375 | 1 | 2 | 3 |
| Front Right | +9.375 | −12.375 | 4 | 5 | 6 |
| Back Left | −9.375 | +12.375 | 10 | 50 | 12 |
| Back Right | −9.375 | −12.375 | 7 | 8 | 9 |
Alpha bot
| Module | X (in) | Y (in) | Drive ID | Steer ID | Encoder ID |
|---|
| Front Left | +12.375 | +10.5 | 1 | 2 | 3 |
| Front Right | +12.375 | −10.5 | 4 | 5 | 6 |
| Back Left | −12.375 | +10.5 | 7 | 8 | 9 |
| Back Right | −12.375 | −10.5 | 10 | 11 | 12 |
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.