Module pid

A basic PID type and common PID operations.

This may be useful when working with control systems.

An introduction to PIDs can be found on Wikipedia.

Constructors

new (target, p, i, d, discrete) Constructs a new PID controller for either a scalar, vector, or quaternion target.

Class PID

pid.sp The setpoint to reach.
pid.kp The proportional gain - how aggressively to respond to the current error
pid.ki The integral gain - how aggressively to eliminate accumulated error
pid.kd The derivative gain - how aggressively to dampen the rate of change
pid.discrete Whether to treat the PID as discrete or continuous
pid:step (self, value, dt) Performs a PID control step Uses Vector or Quaternion types when applicable.
pid:clampOutput (self, min, max) Enables/disables the clamping of the output value
pid:limitIntegral (self, min, max) Enables/disables the integral limits for anti-windup
pid:tostring (self) Converts the PID instance into a human-readable string


Constructors

new (target, p, i, d, discrete)
Constructs a new PID controller for either a scalar, vector, or quaternion target.

See also:

Usage:

    pid = pid.new(target)

Class PID

A PID, with a scalar, vector, or quaternion setpoint, kP, kI, and kD, both as discrete and continuous.
pid.sp
The setpoint to reach. Uses Vector or Quaternion types when applicable.

See also:

pid.kp
The proportional gain - how aggressively to respond to the current error
pid.ki
The integral gain - how aggressively to eliminate accumulated error
pid.kd
The derivative gain - how aggressively to dampen the rate of change
pid.discrete
Whether to treat the PID as discrete or continuous
pid:step (self, value, dt)
Performs a PID control step Uses Vector or Quaternion types when applicable.

See also:

Usage:

  • output = pid:step(value)
  • output = pid:step(value, 0.5)
pid:clampOutput (self, min, max)
Enables/disables the clamping of the output value
pid:limitIntegral (self, min, max)
Enables/disables the integral limits for anti-windup
pid:tostring (self)
Converts the PID instance into a human-readable string
generated by LDoc 1.5.0 Last updated 2025-11-21 05:09:11