YAGSL
  • Welcome to Yet Another Swerve Document
    • Resources
  • Overview
    • What we do
    • Our Features
      • Telemetry
      • Simulation
      • Lock Pose
      • Max Speed
      • Chassis Speed Discretization
      • Vision Odometry
      • Heading Correction
      • Auto-centering Modules
      • Offset Offloading
      • Cosine Compensation
      • Module Auto-synchronization
      • Angular Velocity Compensation
    • Changelog
    • Java API
    • Example Code
    • Config Generator
    • 💸Donations
    • 👕Merch
    • Discord
  • Fundamentals
    • Swerve Drive
    • Swerve Modules
  • Bringing up swerve
    • Preface
    • Swerve Information
    • Check your gyroscope
    • Check your motors
    • Creating your first configuration
  • Configuring YAGSL
    • Getting to know your robot
      • Gear Ratio
    • Dependency Installation
    • Configuration
      • Swerve Drive Configuration
      • Physical Properties Configuration
      • PIDF Properties Configuration
        • PIDF
      • Swerve Module Configuration
      • Controller Properties Configuration
      • Device Configuration
    • Code Setup
    • Standard Conversion Factors
    • How to tune PIDF
    • When to invert?
    • Flowcharts
    • The eight steps
    • Swerve Drive Drift
    • SparkMAX Common Problems
    • Verifying your Module Locations
    • Tuning out Drift
  • Devices
    • Gyroscope
      • NavX
      • Pigeon
      • Pigeon 2.0
      • ADXRS450
      • ADIS16448
      • ADIS16470
    • Motor Controllers
      • SparkMAX
      • SparkFlex
      • TalonFX
    • Absolute Encoders
  • Analytics and Debugging
    • FRC Web Components
    • Advantage Scope
  • Product Guides
    • Java API
    • PathPlanner
    • ❌Tuning PID with REV Hardware Client
    • ❌Drive Code
  • Legacy Documentation
Powered by GitBook
On this page
  • The basic idea
  • Tuning PIDF
  • WPI Walkthrough
  • Starting Points

Was this helpful?

Edit on GitHub
  1. Configuring YAGSL

How to tune PIDF

PreviousStandard Conversion FactorsNextWhen to invert?

Last updated 1 year ago

Was this helpful?

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 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.

    • found by 78 found by

Tuning PIDF

Manual tuning typically follows this process:

  1. Set PPP, III and DDD to zero.

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

  3. Increase DDD 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
  }
}

SparkMax

When the angle 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 angle 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
  }
}

Another good way to describe it is

from CTRE
pidfproperties.json
Video
this CD Post
Introduction to PIDFIRST Robotics Competition Documentation
Basics of PID
Logo
Tuning a Flywheel Velocity ControllerFIRST Robotics Competition Documentation
Tuning Velocity, like the drive motors!
Logo
Tuning a Turret Position ControllerFIRST Robotics Competition Documentation
Tuning position, like the steering/angle/azimuth motors!
Logo