Skip to content

PID and Advanced Control Systems

Lyndon Warren edited this page Mar 25, 2024 · 1 revision

PID

It’s the special magic sauce of Mustard. It’s like Grey Poupon. Goes nice with ketchup.



PID is used if we are trying to go from one particular value or position(elevator position, etc.) to another. It has a wide variety of use cases, of which we mainly use it for driving motors to specific values. It involves setting several constants that interact with complex calculations to drive our motors in specific ways. We haven't fully researched it, but to use it for our purposes, see below:

Before jumping into using PID, we need to clarify what motor type we are using. **REVLib** and **Pheonix** use very different systems to assign values and drive motors with them, so make sure to follow the steps listed for your specified motor.

PID has three main variables: **Proportional**, **Integral**, and **Derivative**. We don’t use integral in FRC. **Proportional** drives the value towards the target value. **Derivative** compensates for error.

There are also a few other values which are used for **feedforward**, a way of compensating for external factors before

To start, create PIDController object and variables to store the P, I, and D (either do testing and/or run SysID to get the values):

private static final double kP = 1.32;
private static final double kI = 0;
private static final double kD = .0185;

PIDController pid = new PIDController(kP, kI, kD);

Then, to calculate a power based on the PID, do (it returns the power/output):

pid.calculate(current, target);

SysID

Clone this wiki locally