Skip to main content

Class: PidController

Defined in: src/sdk/utils/controllers/PidController.ts:23

A PID controller.

Constructors

Constructor

new PidController(kP, kI, kD, maxOut, minOut, maxI, minI): PidController

Defined in: src/sdk/utils/controllers/PidController.ts:44

Creates a new PidController.

Parameters

ParameterTypeDefault valueDescription
kPnumberundefinedThe proportional gain of the controller.
kInumberundefinedThe integral gain of the controller.
kDnumberundefinedThe differential gain of the controller.
maxOutnumberundefinedThe maximum output of the controller.
minOutnumberundefinedThe minumum output of the controller.
maxInumberNumber.MAX_SAFE_INTEGERThe maximum integral gain.
minInumberNumber.MIN_SAFE_INTEGERThe minimum integral gain.

Returns

PidController

Methods

getOutput()

getOutput(deltaTime, error): number

Defined in: src/sdk/utils/controllers/PidController.ts:62

Gets the output of the PID controller at a given time.

Parameters

ParameterTypeDescription
deltaTimenumberThe difference in time between the previous sample and this sample.
errornumberThe amount of error seen between the desired output and the current output.

Returns

number

The PID output.


getPreviousError()

getPreviousError(): undefined | number

Defined in: src/sdk/utils/controllers/PidController.ts:52

Gets this controller's most recent error input since it was created or reset.

Returns

undefined | number

This controller's most recent error input since it was created or reset.


reset()

reset(): void

Defined in: src/sdk/utils/controllers/PidController.ts:83

Resets the controller.

Returns

void


clamp()

static clamp(value, max, min): number

Defined in: src/sdk/utils/controllers/PidController.ts:96

Clamps a number to maximum and minimum values.

Parameters

ParameterTypeDescription
valuenumberThe value to clamp.
maxnumberThe maximum value.
minnumberThe minumum value.

Returns

number

The clamped value.