PIDController

class PIDController @JvmOverloads constructor(val coefficients: PIDCoefficients, val resetIntegralOnZeroCrossover: Boolean = true)(source)

Traditional proportional-integral-derivative controller.

Parameters

coefficients

the PIDCoefficients that contains the PID gains

resetIntegralOnZeroCrossover

whether to reset the integral term when the error crosses

Constructors

Link copied to clipboard
constructor(coefficients: PIDCoefficients, resetIntegralOnZeroCrossover: Boolean = true)
constructor(kP: Double, kI: Double = 0.0, kD: Double = 0.0, resetIntegralOnZeroCrossover: Boolean = true)

Creates a PIDController with the given coefficients.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Returns true if continuous input is enabled.

Link copied to clipboard

Functions

Link copied to clipboard
fun calculate(timestamp: ComparableTimeMark = TimeSource.Monotonic.markNow(), error: MotionState<*>): Double

Calculates the PID output from an error MotionState.

fun <U : Unit<U>> calculate(timestamp: ComparableTimeMark = TimeSource.Monotonic.markNow(), reference: MotionState<U>, measured: MotionState<U>): Double

Calculates the PID output from reference and measured MotionStates.

fun calculate(timestamp: ComparableTimeMark = TimeSource.Monotonic.markNow(), error: Double, errorDerivative: Double? = null): Double

Calculates the PID output

@JvmName(name = "calculateFromReference")
fun calculate(timestamp: ComparableTimeMark = TimeSource.Monotonic.markNow(), reference: Double, measured: Double, measuredDerivative: Double? = null): Double

Calculates the PID output from a reference (setpoint) and measured value.

@JvmName(name = "calculateFromReference")
fun calculate(timestamp: ComparableTimeMark = TimeSource.Monotonic.markNow(), reference: Double, measured: Double, referenceDerivative: Double, measuredDerivative: Double): Double

Calculates the PID output from a reference (setpoint) and measured value, with their respective derivatives.

Link copied to clipboard

Disables continuous input.

Link copied to clipboard
fun enableContinuousInput(minimumInput: Double, maximumInput: Double)

Enables continuous input.

Link copied to clipboard
fun reset()

Resets the PID controller

Link copied to clipboard
fun setIntegratorRange(minimumIntegral: Double, maximumIntegral: Double)

Sets the range the accumulated error (integral term) is clamped to, to prevent unbounded windup while the error stays the same sign (e.g. an arm held against a mechanical stop, or fighting a constant load). Defaults to unbounded.