Skip to main content

Class: PidController

A PID controller.

Constructors

constructor

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

Creates a new PidController.

Parameters

NameTypeDefault 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

Defined in

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

Methods

getOutput

getOutput(deltaTime, error): number

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

Parameters

NameTypeDescription
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.

Defined in

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


getPreviousError

getPreviousError(): undefined | number

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.

Defined in

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


reset

reset(): void

Resets the controller.

Returns

void

Defined in

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


clamp

clamp(value, max, min): number

Clamps a number to maximum and minimum values.

Parameters

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

Returns

number

The clamped value.

Defined in

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