How to tune PIDF

Swerve steering/angle/azimuth motors have PID wrapping enabled at the topmost and bottommost point (e.g "front" and "back") when tuning your PID you may want to test with left or right translation.

The basic idea

YAGSL has PIDF values in pidfproperties.json within the swerve module folder.

This has been hashed and boiled down to the simplest form like this before.

  • P: if you’re not where you want to be, get there.

  • I: if you haven’t been where you want to be for a long time, get there faster

  • D: if you’re getting close to where you want to be, slow down.

Tuning PIDF

Another good way to describe it from CTRE is

Manual tuning typically follows this process:

  1. Set PP, II and DD to zero.

  2. Increase PP until the output starts to oscillate around the setpoint.

  3. Increase DD as much as possible without introducing jittering to the response.

WPI Walkthrough

WPILib has lots of great documentation including PID so I would highly encourage you to check it out!

Starting Points

The PIDF values will vary for every robot so tuning and testing are required. Here are some starting points I have documented with the types of motor controllers they correspond to.

SparkMax

When the drive motor type for every module is sparkmax then this is what the starting point can be.

{
  "drive": {
    "p": 0.0020645,
    "i": 0,
    "d": 0,
    "f": 0,
    "iz": 0
  },
  "angle": {
    "p": 0.01,
    "i": 0,
    "d": 0,
    "f": 0,
    "iz": 0
  }
}

TalonFX

When the drive motor type for every module is talonfx or alike (kraken/falcon) then this is what the starting point can be.

{
  "drive": {
    "p": 1,
    "i": 0,
    "d": 0,
    "f": 0,
    "iz": 0
  },
  "angle": {
    "p": 50,
    "i": 0,
    "d": 0.32,
    "f": 0,
    "iz": 0
  }
}

Last updated