public abstract class PIDSubsystem extends Subsystem implements Sendable
| Modifier and Type | Field and Description |
|---|---|
(package private) PIDController |
m_controller |
(package private) PIDSink |
m_sink |
(package private) PIDSource |
m_source |
| Constructor and Description |
|---|
PIDSubsystem(double p,
double i,
double d)
Instantiates a
PIDSubsystem that will use the given p, i and d values. |
PIDSubsystem(double p,
double i,
double d,
double f)
Instantiates a
PIDSubsystem that will use the given p, i and d values. |
PIDSubsystem(double p,
double i,
double d,
double f,
double period)
Instantiates a
PIDSubsystem that will use the given p, i and d values. |
PIDSubsystem(java.lang.String name,
double p,
double i,
double d)
Instantiates a
PIDSubsystem that will use the given p, i and d values. |
PIDSubsystem(java.lang.String name,
double p,
double i,
double d,
double f)
Instantiates a
PIDSubsystem that will use the given p, i and d values. |
PIDSubsystem(java.lang.String name,
double p,
double i,
double d,
double f,
double period)
Instantiates a
PIDSubsystem that will use the given p, i and d values. |
| Modifier and Type | Method and Description |
|---|---|
void |
disable()
Disables the internal
PIDController |
void |
enable()
Enables the internal
PIDController |
PIDController |
getPIDController()
Returns the
PIDController used by this PIDSubsystem. |
double |
getPosition()
Returns the current position
|
double |
getSetpoint()
Returns the setpoint.
|
java.lang.String |
getSmartDashboardType() |
void |
initTable(ITable table) |
boolean |
onTarget()
Return true if the error is within the percentage of the total input range,
determined by setTolerance.
|
protected abstract double |
returnPIDInput()
Returns the input for the pid loop.
|
void |
setAbsoluteTolerance(double t)
Set the absolute error which is considered tolerable for use with
OnTarget.
|
void |
setInputRange(double min,
double max)
Sets the maximum and minimum values expected from the input and setpoint.
|
void |
setOutputRange(double min,
double max)
Sets the maximum and minimum values to write.
|
void |
setPercentTolerance(double p)
Set the percentage error which is considered tolerable for use with
OnTarget.
|
void |
setSetpoint(double point)
Sets the setpoint to the given value.
|
void |
setSetpointRelative(double deltaSetpoint)
Adds the given value to the setpoint.
|
protected abstract void |
usePIDOutput(double output)
Uses the value that the pid loop calculated.
|
confirmCommand, getCurrentCommand, getCurrentCommandNotInterruptable, getDefaultCommand, getName, getTable, initDefaultCommand, iterationRun, nullifyCurrentCommand, setCurrentCommand, setDefaultCommand, toStringfinal PIDController m_controller
final PIDSink m_sink
final PIDSource m_source
public PIDSubsystem(java.lang.String name,
double p,
double i,
double d)
PIDSubsystem that will use the given p, i and d values.name - the namep - the proportional valuei - the integral valued - the derivative valuepublic PIDSubsystem(java.lang.String name,
double p,
double i,
double d,
double f)
PIDSubsystem that will use the given p, i and d values.name - the namep - the proportional valuei - the integral valued - the derivative valuef - the feed forward valuepublic PIDSubsystem(java.lang.String name,
double p,
double i,
double d,
double f,
double period)
PIDSubsystem that will use the given p, i and d values. It will also space the time
between PID loop calculations to be equal to the given period.name - the namep - the proportional valuei - the integral valued - the derivative valueperiod - the time (in seconds) between calculationspublic PIDSubsystem(double p,
double i,
double d)
PIDSubsystem that will use the given p, i and d values.
It will use the class name as its name.p - the proportional valuei - the integral valued - the derivative valuepublic PIDSubsystem(double p,
double i,
double d,
double f)
PIDSubsystem that will use the given p, i and d values.
It will use the class name as its name.
It will also space the time
between PID loop calculations to be equal to the given period.p - the proportional valuei - the integral valued - the derivative valuef - the feed forward coefficientperiod - the time (in seconds) between calculationspublic PIDSubsystem(double p,
double i,
double d,
double f,
double period)
PIDSubsystem that will use the given p, i and d values.
It will use the class name as its name.
It will also space the time
between PID loop calculations to be equal to the given period.p - the proportional valuei - the integral valued - the derivative valueperiod - the time (in seconds) between calculationspublic final PIDController getPIDController()
PIDController used by this PIDSubsystem.
Use this if you would like to fine tune the pid loop.PIDController used by this PIDSubsystempublic final void setSetpointRelative(double deltaSetpoint)
setInputRange(...) was used,
then the bounds will still be honored by this method.deltaSetpoint - the change in the setpointpublic final void setSetpoint(double point)
setInputRange(...)
was called,
then the given setpoint
will be trimmed to fit within the range.point - the new setpointpublic final double getSetpoint()
public final double getPosition()
public final void setInputRange(double min,
double max)
min - the minimum value expected from the input and setpointmax - the maximum value expected from the input and setpointpublic final void setOutputRange(double min,
double max)
min - the minimum value to write to the outputmax - the maximum value to write to the outputpublic final void setAbsoluteTolerance(double t)
t - the absolute tolerancepublic final void setPercentTolerance(double p)
p - the percent tolerancepublic final boolean onTarget()
protected abstract double returnPIDInput()
It returns the input for the pid loop, so if this Subsystem was based off of a gyro, then it should return the angle of the gyro
All subclasses of PIDSubsystem must override this method.
protected abstract void usePIDOutput(double output)
driveline.tankDrive(output, -output)
All subclasses of PIDSubsystem must override this method.
output - the value the pid loop calculatedpublic final void enable()
PIDControllerpublic final void disable()
PIDControllerpublic final java.lang.String getSmartDashboardType()
getSmartDashboardType in interface SendablegetSmartDashboardType in class Subsystem