Class PidTunables

java.lang.Object
com.crossbotics.ftchelper.tuning.PidTunables

public final class PidTunables extends Object
The four PID gains of one controller as Tunables, in one line.

 static final PidTunables LIFT = PidTunables.of("Lift", 0.004, 0, 0.0002, 0.05);
 // every loop:
 LIFT.applyTo(liftPid);
 
The menu then shows "Lift/kP", "Lift/kI", "Lift/kD" and "Lift/kF". Steps are 1/8 of each starting value (or small defaults when a value is 0).

What the four gains do: see PidController and Tutorial 07 (docs/tutorials/07-pid-lift.md). Docs: docs/guides/tuning.md

  • Field Details

    • kP

      public final Tunable kP
      The four gains, each one changeable from the TuningMenu. "final": set once, never replaced.
    • kI

      public final Tunable kI
      The four gains, each one changeable from the TuningMenu. "final": set once, never replaced.
    • kD

      public final Tunable kD
      The four gains, each one changeable from the TuningMenu. "final": set once, never replaced.
    • kF

      public final Tunable kF
      The four gains, each one changeable from the TuningMenu. "final": set once, never replaced.
  • Method Details

    • of

      public static PidTunables of(String group, double kP, double kI, double kD, double kF)
      Makes the four tunables "group/kP" ... "group/kF".
      Parameters:
      group - the name shown in the menu, e.g. "Lift"
      kP - the P gain in your code
      kI - the I gain in your code
      kD - the D gain in your code
      kF - the feedforward in your code
      Returns:
      the four tunables together
    • applyTo

      public void applyTo(PidController pid)
      Copies the current values into the controller. Call every loop, so a change in the menu is felt on the robot right away.
      Parameters:
      pid - the controller to update