Class PIDProcessor<I,​O>

    • Constructor Detail

      • PIDProcessor

        protected PIDProcessor​(double p,
                               double i,
                               double d)
        Create a new PIDProcessor.
        Parameters:
        p - The P coefficient.
        i - The I coefficient.
        d - The D coefficient.
    • Method Detail

      • getError

        protected abstract double getError​(I data)
        Extract the PID loop target from the data passed to the processor, and calculate the current error.
        Parameters:
        data - The data instance that was passed to the processor's apply() method.
        Returns:
        The error.
      • createOutput

        protected abstract O createOutput​(I data,
                                          double loopOutput)
        Create the processor output.
        Parameters:
        data - The data instance that was passed to the processor's apply() method.
        loopOutput - The output of the PID loop
        Returns:
        The processor's output; this will be returned from the the processor's apply() method.
      • apply

        public O apply​(I input)
        Specified by:
        apply in interface Function<I,​O>
      • getIAccum

        public double getIAccum()
        Gets the current value of the integral accumulator.
        Returns:
        The integral accumulator. If the PID loop has not yet been run (i.e. apply() has not yet been called since instantiation/the last call to reset()), returns 0.
      • getError

        public double getError()
        Gets the closed-loop error from the last run of the PID loop.
        Returns:
        The closed-loop error. If the PID loop has not yet been run (i.e. apply() has not yet been called since instantiation/the last call to reset()), returns 0.
      • reset

        public void reset()
        Resets the PID loop. This clears the integral accumulator and error values, and should be called if the TurningRateClosedLoopProcessor is being reused for multiple discrete occasions (i.e. executions of different motion profile segments). Calling this is functionally equivalent to creating a new processor instance.