PIDFController

This is a PID controller (https://en.wikipedia.org/wiki/PID_controller) for your robot. Internally, it performs all the calculations for you. You need to tune your values to the appropriate amounts in order to properly utilize these calculations.

The equation we will use is: u(t) = kP * e(t) + kI * int(0,t)[e(t')dt'] + kD * e'(t) + kF where e(t) = r(t) - y(t) and r(t) is the setpoint and y(t) is the measured value. If we consider e(t) the positional error, then int(0,t)[e(t')dt'] is the total error and e'(t) is the velocity error. Source

Since

1.0.0-pre

Inheritors

Constructors

Link copied to clipboard
constructor(kp: Double, ki: Double, kd: Double, kf: Double)
The base constructor for the PIDF controller
constructor(kp: Double, ki: Double, kd: Double, kf: Double, sp: Double, pv: Double)
This is the full constructor for the PIDF controller.

Properties

Link copied to clipboard
open var kD: Double
Derivative gain.
Link copied to clipboard
open var kF: Double
Feedforward gain.
Link copied to clipboard
open var kI: Double
Integral gain.
Link copied to clipboard
open var kP: Double
Proportional gain.
Link copied to clipboard
open val period: Double
Link copied to clipboard
@set:NonNull
open var setPoint: Double

Inherited properties

Link copied to clipboard
A null controller that does nothing.

Functions

Link copied to clipboard
open fun atSetPoint(): Boolean
Returns true if the error is within the percentage of the total input range, determined by setTolerance.
Link copied to clipboard
open fun calculate(): Double
open fun calculate(pv: Double, sp: Double): Double
Calculates the next output of the PIDF controller.
open fun calculate(pv: Double): Double
Calculates the control value, u(t).
Link copied to clipboard
Clear the integral term.
Link copied to clipboard
Link copied to clipboard
open fun getD(): Double
Link copied to clipboard
open fun getF(): Double
Link copied to clipboard
open fun getI(): Double
Link copied to clipboard
open fun getP(): Double
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Get the PIDF controller associated with this controller, if applicable.
Link copied to clipboard
open fun reset()
Resets the PIDF controller.
Link copied to clipboard
open fun setCoefficients(@NonNull coeffs: Array<Double>)
Note!
Link copied to clipboard
Set the D coefficient on this controller
Link copied to clipboard
Set the F coefficient on this controller
Link copied to clipboard
Set the I coefficient on this controller
Link copied to clipboard
open fun setIntegrationBounds(integralMin: Double, integralMax: Double): PIDFController
Set the bounds for the integral term.
Link copied to clipboard
Clamps the maximum output magnitude that can be achieved via calculate.
Link copied to clipboard
Set the P coefficient on this controller
Link copied to clipboard
open fun setPIDF(@NonNull coefficients: PIDFCoefficients): PIDFController
open fun setPIDF(kp: Double, ki: Double, kd: Double, kf: Double): PIDFController
Set the current controller PID coefficients to the given coefficients.
Link copied to clipboard
open fun setTolerance(positionTolerance: Double): PIDFController
open fun setTolerance(positionTolerance: Double, velocityTolerance: Double): PIDFController
Sets the error which is considered tolerable for use with atSetPoint.
Link copied to clipboard
open fun updatePIDF(@NonNull coefficients: PIDFCoefficients): PIDFController
Update the supplied PID coefficients with the current controller values.

Inherited functions

Link copied to clipboard
Composes this controller with another controller, returning a new controller that is the composition of the two.
Link copied to clipboard
open fun setCoefficients(@NonNull coeffs: Array<Double>)
Sets the coefficients for this controller.