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

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
fun reset()

Resets the PID controller