Class PIDProcessor<I,O>
- java.lang.Object
-
- org.team1540.rooster.drive.pipeline.PIDProcessor<I,O>
-
- Type Parameters:
I
- The input type of the processor.O
- The output type of the processor.
- Direct Known Subclasses:
HeadingPIDProcessor
,TurningRatePIDProcessor
public abstract class PIDProcessor<I,O> extends Object implements Processor<I,O>
Processor to execute a generic PID loop.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PIDProcessor(double p, double i, double d)
Create a newPIDProcessor
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description O
apply(I input)
protected abstract O
createOutput(I data, double loopOutput)
Create the processor output.double
getError()
Gets the closed-loop error from the last run of the PID loop.protected abstract double
getError(I data)
Extract the PID loop target from the data passed to the processor, and calculate the current error.double
getIAccum()
Gets the current value of the integral accumulator.void
reset()
Resets the PID loop.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.team1540.rooster.functional.Processor
followedBy, process
-
-
-
-
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'sapply()
method.- Returns:
- The error.
-
createOutput
protected abstract O createOutput(I data, double loopOutput)
Create the processor output.
-
getIAccum
public double getIAccum()
Gets the current value of the integral accumulator.
-
getError
public double getError()
Gets the closed-loop error from the last run of the PID loop.
-
reset
public void reset()
Resets the PID loop. This clears the integral accumulator and error values, and should be called if theTurningRateClosedLoopProcessor
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.
-
-