Swerve Setup Guide 2025 Help

TalonFX Swerve Tuning

Here, you will find many tutorials on how to tune aspects of the swerve template.

Feedforward Characterization

The project includes default feedforward gains. Provided are three SysID tests. You will change m_sysIdRoutineToApply inside of Drive.java to change the type of test.

Translation and Steer are needed. A Rotation test is also needed to find MOI.

Running FeedForward Test

  1. Place the robot in an open space.

  2. Connect robot and controller to driver station.

  3. Enable the robot.

  4. Hold down select, and hold y for 4 seconds or longer.

  5. Hold down select, and hold x for 4 seconds or longer.

  6. Hold down start, and hold y for 4 seconds or longer.

  7. Hold down start, and hold x for 4 seconds or longer.

  8. Disable the robot.

Saving The Test

  1. Go to File > Download Logs...

  2. Select the log that is most recent.

  3. Go to File > Export Data...

  4. Set the format to WPILOG and the timestamps to AdvantageKit Cycles. For large log files, enter the prefixes for only the fields and tables necessary for SysId analysis (see the export options: documentation for details).

  5. Click the save icon and choose a location to save the log.

Running SysID

  1. Open SysID in the "2025 WPILib Tools" folder on your desktop.

  2. Open your log

  3. Drag RealOutputs/SysIdRotation_State to the Data Selector

  4. Drag Module0/DrivePosition, Module0/DriveVelocity, Module0/DriveAppliedVolts to their respective locations

  5. Change the Mechanism type to Simple

  6. Change the Units to Radians

  7. Load

Values to Use

  1. For Drive FeedForward - Use kV - Log kA for MOI

  2. For Steer FeedForward - Use kS and kV

  3. For Rotation FeedForward - Log kA

We have found that these FeedForward values are accurate, but the PID is not always.

Drive/Turn PID Tuning

The project includes default gain, which can be found in the steerGains and driveGains configs in TunerConstants.java. These gains should be tuned for each robot.

PID Tuning Tips

  1. For Drive PID - Only use kP

  2. For Steer PID - Use kP and kD

TorqueCurrent Control

Congrats! You should have a fully tuned robot. For Phoenix Pro you can also attempt to use TorqueCurrent control, as described in the Phoenix documentation. You can configure by changing the values of kSteerClosedLoopOutput and/or kDriveClosedLoopOutput in TunerConstants.java to ClosedLoopOutputType.TorqueCurrentFOC.

Wheel Radius Characterization

The effective wheel radius of a robot tends to change over time as wheels are worn down, swapped, or compressed into the carpet. Having the wrong wheel size can have significant impacts on odometry accuracy. We recommend regularly recharacterizing wheel radius to combat these issues.

The project includes an automated wheel radius characterization routine, which only requires enough space for the robot to rotate in place.

  1. Place the robot on the carpet. Characterizing on a hard floor may produce errors in the measurement, as the robot's effective wheel radius is affected by carpet compression.

  2. Select the "Drive Wheel Radius Characterization" auto routine.

  3. Enable the robot in autonomous mode. The robot will slowly rotate in place.

  4. Disable the robot after at least one full rotation.

  5. Check the console output for the measured wheel radius, and copy the value to kWheelRadius in TunerConstants.java.

Max Speed Measurement

The effective maximum speed of a robot is typically slightly less than the theoretical max speed based on motor free speed and gearing. To ensure that the robot remains controllable at high speeds, we recommend measuring the effective maximum speed of the robot.

  1. Set kSpeedAt12Volts in TunerConstants.java to the theoretical max speed of the robot based on motor free speed and gearing. This value can typically be found on the product page for your chosen swerve modules.

  2. Place the robot in an open space.

  3. Plot the measured robot speed in AdvantageScope using the /RealOutputs/SwerveChassisSpeeds/Measured field.

  4. In teleop mode, drive forwards at full speed until the robot velocity is no longer increasing.

  5. Record the maximum velocity achieved and update the value of kSpeedAt12Volts.

Slip Current Measurement

The value of kSlipCurrent can be tuned to avoid slipping the wheels.

  1. Place the robot against a solid wall.

  2. Using AdvantageScope, plot the current of a drive motor from the /Drive/Module.../DriveCurrentAmps key, and the velocity of the motor from the /Drive/Module.../DriveVelocityRadPerSec key.

  3. Accelerate forwards until the drive velocity increases (the wheel slips). Note the current at this time.

  4. Update the value of kSlipCurrent to this value.

PathPlanner Configuration

The project includes a built-in robot configuration for PathPlanner, located in the constructor of Drive.java. You will want to update all values:

  • Robot mass, MOI, and wheel coefficient as configured in Constants.java

  • Drive PID constants as configured in AutoBuilder

  • Turn PID constants as configured in AutoBuilder

Swerve Setpoint Generator

This project include skid and slip prevention using PathPlanners Swerve Setpoint Generator

Once you set the PathPlanner Configurations, you can test this drive mode by pressing X button. Once you feel comfortable, replacing the default drive with this is recommended.

Last modified: 01 January 2025