Class HeadingPIDProcessor
- java.lang.Object
-
- org.team1540.rooster.drive.pipeline.PIDProcessor<TankDriveData,TankDriveData>
-
- org.team1540.rooster.drive.pipeline.HeadingPIDProcessor
-
- All Implemented Interfaces:
Function<TankDriveData,TankDriveData>
,Processor<TankDriveData,TankDriveData>
public class HeadingPIDProcessor extends PIDProcessor<TankDriveData,TankDriveData>
APIDProcessor
for maintaining a robot's heading.
-
-
Constructor Summary
Constructors Constructor Description HeadingPIDProcessor(double p, double i, double d, DoubleSupplier headingSupplier)
Create a newHeadingPIDProcessor
without inverted sides that outputs to feed-forward setpoints.HeadingPIDProcessor(double p, double i, double d, DoubleSupplier headingSupplier, boolean outputToPosition)
Create a newHeadingPIDProcessor
without inverted sides.HeadingPIDProcessor(double p, double i, double d, DoubleSupplier headingSupplier, boolean outputToPosition, boolean invertSides)
Create a newHeadingPIDProcessor
.HeadingPIDProcessor(double p, double i, DoubleSupplier headingSupplier)
Create a newHeadingPIDProcessor
without inverted sides that outputs to feed-forward setpoints.HeadingPIDProcessor(double p, DoubleSupplier headingSupplier)
Create a newHeadingPIDProcessor
without inverted sides that outputs to feed-forward setpoints.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TankDriveData
createOutput(TankDriveData data, double loopOutput)
Create the processor output.protected double
getError(TankDriveData data)
Extract the PID loop target from the data passed to the processor, and calculate the current error.-
Methods inherited from class org.team1540.rooster.drive.pipeline.PIDProcessor
apply, getError, getIAccum, reset
-
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
-
-
-
-
Constructor Detail
-
HeadingPIDProcessor
public HeadingPIDProcessor(double p, DoubleSupplier headingSupplier)
Create a newHeadingPIDProcessor
without inverted sides that outputs to feed-forward setpoints.- Parameters:
p
- The P coefficient.headingSupplier
- A supplier that returns the current heading, in radians from -π to π.
-
HeadingPIDProcessor
public HeadingPIDProcessor(double p, double i, DoubleSupplier headingSupplier)
Create a newHeadingPIDProcessor
without inverted sides that outputs to feed-forward setpoints.- Parameters:
p
- The P coefficient.i
- The I coefficient.headingSupplier
- A supplier that returns the current heading, in radians from -π to π.
-
HeadingPIDProcessor
public HeadingPIDProcessor(double p, double i, double d, DoubleSupplier headingSupplier)
Create a newHeadingPIDProcessor
without inverted sides that outputs to feed-forward setpoints.- Parameters:
p
- The P coefficient.i
- The I coefficient.d
- The D coefficient.headingSupplier
- A supplier that returns the current heading, in radians from -π to π.
-
HeadingPIDProcessor
public HeadingPIDProcessor(double p, double i, double d, DoubleSupplier headingSupplier, boolean outputToPosition)
Create a newHeadingPIDProcessor
without inverted sides.- Parameters:
p
- The P coefficient.i
- The I coefficient.d
- The D coefficient.headingSupplier
- A supplier that returns the current heading, in radians from -π to π.outputToPosition
- Whether to output to the position setpoints (as opposed to the feed-forward setpoints.)
-
HeadingPIDProcessor
public HeadingPIDProcessor(double p, double i, double d, DoubleSupplier headingSupplier, boolean outputToPosition, boolean invertSides)
Create a newHeadingPIDProcessor
.- Parameters:
p
- The P coefficient.i
- The I coefficient.d
- The D coefficient.headingSupplier
- A supplier that returns the current heading, in radians from -π to π.outputToPosition
- Whether to output to the position setpoints (as opposed to the feed-forward setpoints.)invertSides
- Whether to invert the output sides. (Iftrue
, the loop output will be added to the left side and subtracted from the right, and vice versa.)
-
-
Method Detail
-
getError
protected double getError(TankDriveData data)
Description copied from class:PIDProcessor
Extract the PID loop target from the data passed to the processor, and calculate the current error.- Specified by:
getError
in classPIDProcessor<TankDriveData,TankDriveData>
- Parameters:
data
- The data instance that was passed to the processor'sapply()
method.- Returns:
- The error.
-
createOutput
protected TankDriveData createOutput(TankDriveData data, double loopOutput)
Description copied from class:PIDProcessor
Create the processor output.- Specified by:
createOutput
in classPIDProcessor<TankDriveData,TankDriveData>
- Parameters:
data
- The data instance that was passed to the processor'sapply()
method.loopOutput
- The output of the PID loop- Returns:
- The processor's output; this will be returned from the the processor's
apply()
method.
-
-