PController

class PController(kP: () -> Double = { 0.005 }) : ControlLoop

This class controls a motor using a proportional coefficient that is applied to the error in order to calculate the power that the motor should be set to during any given time.

Parameters

kP

the proportional coefficient

Constructors

Link copied to clipboard
constructor(kP: Double)

This class controls a motor using a proportional coefficient that is applied to the error in order to calculate the power that the motor should be set to during any given time.

constructor(kP: () -> Double = { 0.005 })

Functions

Link copied to clipboard
open override fun calculate(state: Double, target: Double): Double

Calculates the ideal output.

Link copied to clipboard
open fun initialize()

Initializes the motor controller.

Link copied to clipboard
open override fun isWithinThreshold(state: Double, target: Double, threshold: Double): Boolean

Checks if the motor is within a certain threshold of the target. Used when calculating if the motor should be running still. Checks the absolute value of the error (because it doesn't need to be calculating the direction the motor needs to move) against a threshold.

Link copied to clipboard
open override fun reset()

Reset the control loop. Primarily used for timers but can be as complex as needed.