Class SyncPIDController


  • public class SyncPIDController
    extends java.lang.Object
    Class that performs the math of a PID controller, converting a setpoint and error to an output.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected double calculateD​(double error)
      Calculate the differential output
      protected double calculateF​(double setpoint)
      Calulcate the feedforward output
      protected double calculateI​(double error)
      Calculate the integral output
      double calculateOutput​(double input, double setpoint)
      Gets the output calculated by this PID.
      protected double calculateP​(double error)
      Calculate the proportional output
      double getIMax()
      Gets the iMax constant for the PID.
      double getIZone()
      Gets the iZone constant for the PID.
      double getKD()
      Gets the derivative constant for the PID.
      double getkF()
      Gets the feedforward constant for the PID.
      double getKI()
      Gets the integral constant for the PID.
      double getKP()
      Gets the proportial constant for the PID.
      double getTolerance()
      Gets the tolerance for the PID.
      void reset()
      Resets the controller's saved info about integral and derivative.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SyncPIDController

        public SyncPIDController​(PIDConfiguration constants)
        Constructor that uses a PIDConfiguration object.
        Parameters:
        constants - Contains all of the PID constants for this PID controller
    • Method Detail

      • getKP

        public double getKP()
        Gets the proportial constant for the PID.
        Returns:
        The proportional gain.
      • getKI

        public double getKI()
        Gets the integral constant for the PID.
        Returns:
        The integral gain.
      • getKD

        public double getKD()
        Gets the derivative constant for the PID.
        Returns:
        The differential gain.
      • getkF

        public double getkF()
        Gets the feedforward constant for the PID.
        Returns:
        the feedforward gain.
      • getIZone

        public double getIZone()
        Gets the iZone constant for the PID.
        Returns:
        the maximum error for integral accumulation.
      • getIMax

        public double getIMax()
        Gets the iMax constant for the PID.
        Returns:
        The maximum accumulated error.
      • getTolerance

        public double getTolerance()
        Gets the tolerance for the PID.
        Returns:
        The max error to consider the PID on target.
      • reset

        public void reset()
        Resets the controller's saved info about integral and derivative. Should be called right before the first use of the controller after it hasn't been used for a while.
      • calculateOutput

        public double calculateOutput​(double input,
                                      double setpoint)
        Gets the output calculated by this PID.
        Parameters:
        input - The current input value
        setpoint - The target input value
        Returns:
        The output value
      • calculateP

        protected double calculateP​(double error)
        Calculate the proportional output
        Parameters:
        error - The current error
        Returns:
        The proportional output
      • calculateI

        protected double calculateI​(double error)
        Calculate the integral output
        Parameters:
        error - The current error
        Returns:
        The integral output
      • calculateD

        protected double calculateD​(double error)
        Calculate the differential output
        Parameters:
        error - The current error
        Returns:
        The differential output
      • calculateF

        protected double calculateF​(double setpoint)
        Calulcate the feedforward output
        Parameters:
        setpoint - The current setpoint
        Returns:
        The feedforward output