Class TrcCascadePidController

java.lang.Object
trclib.robotcore.TrcPidController
trclib.archive.TrcCascadePidController

public class TrcCascadePidController extends TrcPidController
This class implements a Cascade PID Controller. A Cascade PID controller consists of two PID controllers in cascade. The output of the primary PID controller feeds into the input of the secondary PID controller. If the motor is not linear, it may be very difficult to get good performance out of a single PID controller. In Cascade PID control, the distance set-point, for example, will produce a speed control as the primary output and feeds into the secondary PID controller as input that will try to compensate for the non-linearity of the motor or even battery level changes. The TrcCascadePidController class extends a regular PID control as its primary PID controller and creates a second PID controller as its secondary controller.
  • Field Details

  • Constructor Details

    • TrcCascadePidController

      public TrcCascadePidController(String instanceName, TrcPidController.PidCoefficients primaryPidCoefficients, TrcPidController.PidCoefficients secondaryPidCoefficients, TrcPidController.PidInput primaryInput, TrcPidController.PidInput secondaryInput)
      Constructor: Create an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      primaryPidCoefficients - specifies the PID coefficients of the primary PID controller.
      secondaryPidCoefficients - specifies the PID coefficients of the secondary PID controller.
      primaryInput - specifies the supplier of the primary PID input.
      secondaryInput - specifies the supplier of the secondary PID input.
  • Method Details

    • reset

      public void reset()
      This method is called to reset the Cascade PID controller. It resets both the primary and secondary PID controller.
      Overrides:
      reset in class TrcPidController
    • getOutput

      public double getOutput()
      This method calculates the Cascade PID control output by calling the primary PID controller, feeding its output to the secondary PID controller and finally returning the output of the secondary PID controller.
      Overrides:
      getOutput in class TrcPidController
      Returns:
      output of the Cascade PID controller.