TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/spectrum3847/2026-Spectrum/llms.txt
Use this file to discover all available pages before exploring further.
Swerve subsystem extends CTRE’s SwerveDrivetrain class and integrates field-centric driving, autonomous path following, zone-based triggers, and pose estimation into a single command-based subsystem. Each of the four swerve modules is powered by a Kraken X60 FOC drive motor and a Kraken X60 FOC steer motor, communicating over the CANIVORE bus via Phoenix 6.
Hardware and initialization
Swerve is constructed with a SwerveConfig that carries drivetrain constants, module positions, and PID gains. During construction the robot seeds its pose to the field center, configures PathPlanner, and starts a high-rate simulation notifier when running in simulation.
Swerve.java
MapleSimSwerveDrivetrain.
Drive requests
SwerveStates pre-configures four CTRE swerve requests that are reused across all commands:
| Request | Usage |
|---|---|
SwerveRequest.FieldCentric | Normal field-centric teleop driving |
SwerveRequest.RobotCentric | Robot-centric / FPV driving |
SwerveRequest.SwerveDriveBrake | X-brake lock during launch |
SwerveRequest.FieldCentricFacingAngle | Aim-assist rotation toward a target |
SwerveStates.java
Driver control bindings
The default command ispilotDrive, which maps the left stick to translation and the right stick to rotation. When the robot is in a LAUNCH_WITH_SQUEEZE, LAUNCH_WITHOUT_SQUEEZE, or TRACK_TARGET state the swerve automatically switches to pilotAimAtTarget, rotating the chassis toward the shot angle calculated by ShotCalculator. Alliance color is accounted for — the blue-alliance version adds 180° to the drive angle.
SwerveStates.java
upReorient, leftReorient, downReorient, rightReorient) and snaps the gyro heading without affecting translation.
Zone-based field positioning triggers
Swerve exposes two high-level zone Triggers used by RobotStates to gate mechanism behavior:
inNeutralZone()
inNeutralZone()
Returns
true when the robot is inside the neutral (center) zone of the REBUILT field. The zone is a Rectangle2d centered at mid-field with a depth of 283 in and length of 317.7 in.Swerve.java
inEnemyAllianceZone()
inEnemyAllianceZone()
Returns
true when the alliance-flipped X coordinate of the robot is inside the opponent’s alliance zone (the last 180 in of the field). FieldHelpers.flipXifRed handles the Blue/Red mirroring automatically.Swerve.java
SwerveStates exposes these as public static helpers so RobotStates can compose them without depending directly on the Swerve instance:
SwerveStates.java
Pose estimation and odometry
Pose is read fromgetState().Pose (provided by the Phoenix SwerveDrivetrain base class), which fuses wheel odometry with vision measurements added externally by the Vision subsystem. In simulation the pose comes from the MapleSimSwerveDrivetrain physics model instead. getPoseAtTimestamp uses Phoenix’s built-in pose buffer to interpolate historical poses for latency-compensated vision updates.
PathPlanner integration
AutoBuilder.configure registers the swerve as the path-following subsystem. Translation is controlled by a PPHolonomicDriveController with separate PID constants (P=4 for translation, P=3 for rotation). The AutoRequest uses DriveRequestType.Velocity and desaturates wheel speeds to handle high-speed autonomous segments.
SwerveStates source
Trigger bindings and all drive command factories.
Swerve source
Zone triggers, pose methods, and PathPlanner configuration.
