Package ca.team3161.lib.robot.pid
Class SimplePID
- java.lang.Object
-
- ca.team3161.lib.robot.pid.AbstractPID<edu.wpi.first.wpilibj.PIDSource,java.lang.Float>
-
- ca.team3161.lib.robot.pid.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.
-
-
Field Summary
-
Fields inherited from class ca.team3161.lib.robot.pid.AbstractPID
deadband, deadbandPeriod, deadbandUnit, deltaError, integralError, kD, kI, kP, lastTimeNotAtTarget, prevError, source
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<PIDSrc<edu.wpi.first.wpilibj.PIDSource,java.lang.Float>>getComposedComponents()Get the composed components within this one.java.lang.Floatpid(java.lang.Float target)Iterate the PID loop.
-
-
-
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 sensordeadband- filter value - do not act when current error is within this bounddeadbandPeriod- the amount of time to remain within acceptable error of the target value before claiming to actually be at the targetdeadbandUnit- the units for deadbandPeriodkP- P constantkI- I constantkD- D constant
-
-
Method Detail
-
pid
public java.lang.Float pid(java.lang.Float target)
Iterate the PID loop.- Specified by:
pidin interfacePID<edu.wpi.first.wpilibj.PIDSource,java.lang.Float>- Specified by:
pidin classAbstractPID<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:
getComposedComponentsin interfaceComposedComponent<PIDSrc<edu.wpi.first.wpilibj.PIDSource,java.lang.Float>>- Returns:
- the composed components.
-
-