Class SimplePID

  • All Implemented Interfaces:
    PID<edu.wpi.first.wpilibj.PIDSource,​java.lang.Float>, ComposedComponent<PIDSrc<edu.wpi.first.wpilibj.PIDSource,​java.lang.Float>>

    public class SimplePID
    extends AbstractPID<edu.wpi.first.wpilibj.PIDSource,​java.lang.Float>
    implements ComposedComponent<PIDSrc<edu.wpi.first.wpilibj.PIDSource,​java.lang.Float>>
    A plain, general PID implementation. A PID loop, which uses a PIDSrc and a set of constants to iteratively determine output values with which a system can reach and maintain a target value.
    • Constructor Detail

      • SimplePID

        public SimplePID​(PIDSrc<edu.wpi.first.wpilibj.PIDSource,​java.lang.Float> source,
                         float deadband,
                         int deadbandPeriod,
                         java.util.concurrent.TimeUnit deadbandUnit,
                         float kP,
                         float kI,
                         float kD)
        Create a new SimplePID instance.
        Parameters:
        source - the PIDSrc source sensor
        deadband - filter value - do not act when current error is within this bound
        deadbandPeriod - the amount of time to remain within acceptable error of the target value before claiming to actually be at the target
        deadbandUnit - the units for deadbandPeriod
        kP - P constant
        kI - I constant
        kD - D constant
    • Method Detail

      • pid

        public java.lang.Float pid​(java.lang.Float target)
        Iterate the PID loop.
        Specified by:
        pid in interface PID<edu.wpi.first.wpilibj.PIDSource,​java.lang.Float>
        Specified by:
        pid in class AbstractPID<edu.wpi.first.wpilibj.PIDSource,​java.lang.Float>
        Parameters:
        target - the desired target value. Units depend on the context of this PID
        Returns:
        the output value to set to eg a SpeedController to reach the specified target
      • getComposedComponents

        public java.util.Collection<PIDSrc<edu.wpi.first.wpilibj.PIDSource,​java.lang.Float>> getComposedComponents()
        Get the composed components within this one.
        Specified by:
        getComposedComponents in interface ComposedComponent<PIDSrc<edu.wpi.first.wpilibj.PIDSource,​java.lang.Float>>
        Returns:
        the composed components.