Skip to main content
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

PID and feedforward gains

Steer gains (Slot 0)

Drive gains (Slot 0)

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.

Alpha bot

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:
The factory itself:

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:
The result is logged via DataLogManager at command end. To run it, hold Y on the launcherTuningController (port assigned in Controls.java):
The drive-base radius used in the calculation is computed automatically from the module LocationX/LocationY values in CompTunerConstants:
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.