Documentation Index
Fetch the complete documentation index at: https://mintlify.com/saquer916/odyssey/llms.txt
Use this file to discover all available pages before exploring further.
PIDController is a standard discrete PID controller used by Follower for translational and heading error correction. It derives dt from successive currentTime arguments, supports symmetric output clamping, and prevents integral wind-up via an independently configurable integral cap. Both Follower controllers operate with setPoint = 0.
Package: org.firstinspires.ftc.teamcode.odyssey.control
Constructor
The desired value the controller drives toward. Both
Follower controllers use 0.0 — the error is encoded in the sign and magnitude of the input passed to getOutput().Proportional gain. Scales the raw error
(setPoint - currentValue) directly.Integral gain. Scales the accumulated error over time. Start with
0 — integral gain is rarely required when kV and kA feedforward are properly tuned. See tip below.Derivative gain. Scales the finite-difference rate of change of error between successive calls. Helps dampen oscillation caused by high kP values.
Methods
getOutput(double currentTime, double currentValue) → double
dt is derived internally as currentTime - previousTime; on the very first call dt is treated as 0, making the derivative term 0 and preventing a spike from an undefined initial state.
The integral term accumulates as integralError += error * dt. If setMaxIntegral() has been called and kI ≠ 0, the integral contribution kI * integralError is clamped to [-maxIntegral, +maxIntegral] before the gains are applied.
PID output:
kP·error + kI·integralError + kD·derivativeError, clamped to [minLimit, maxLimit] if output limits have been set.reset()
previousTime to NaN. The next getOutput() call will behave as if it is the first call — dt will be 0 and no derivative spike will occur.
setSetpoint(double setPoint)
lastError and integralError) to prevent a sudden derivative or integral jolt from the old error state.
setOutputLimits(double minLimit, double maxLimit)
getOutput() to [minLimit, maxLimit]. If minLimit > maxLimit, the arguments are swapped automatically so the smaller value is always the lower bound.
removeOutputLimits()
NaN. getOutput() will return unclamped values until setOutputLimits() is called again.
setMaxIntegral(double maxIntegral)
kI * integralError) to [-maxIntegral, +maxIntegral], preventing integrator wind-up. The stored value is always positive (Math.abs(maxIntegral) is used internally). Wind-up protection is active only when kI ≠ 0.
Gain accessors and mutators
resetErrors() internally — zeroing lastError and integralError — so a gain change mid-run does not produce a derivative spike or carry forward a stale integral from the old gain regime.
getSetPoint() → double
The value most recently set by the constructor or
setSetpoint().Usage example
Calling
setkP(), setkI(), or setkD() resets error accumulators via an internal resetErrors() call. This zeroes lastError and integralError, preventing a derivative spike or integral carry-over when gains are changed while the controller is already running.