LQRController

constructor(qX: Double, qY: Double, qHeading: Double, qVx: Double, qVy: Double, qOmega: Double, rAx: Double, rAy: Double, rAlpha: Double, dt: Double = 0.0303)

Constructor for the common holonomic robot control use case.

This constructor assumes a kinematic acceleration model where the state error x is [xError, yError, headingError, vxError, vyError, omegaError] and the control input u is the desired robot acceleration [ax, ay, alpha].

The system dynamics are approximated as: dx_dot = vx dy_dot = vy dtheta_dot = omega dvx_dot = ax dvy_dot = ay domega_dot = alpha

Parameters

qX

The maximum error in the x-position.

qY

The maximum error in the y-position.

qHeading

The maximum error in the heading.

qVx

The maximum error in the x-velocity.

qVy

The maximum error in the y-velocity.

qOmega

The maximum error in the angular velocity.

rAx

The maximum linear acceleration in the x-direction.

rAy

The maximum using linear acceleration in the y-direction.

rAlpha

The maximum angular acceleration.

dt

The discrete time step (control loop period) in seconds.


constructor(A: Matrix, B: Matrix, Q: Matrix, R: Matrix, dt: Double = 0.0303)

General-purpose constructor for any linear time-invariant (LTI) system.

This constructor is for advanced users who have a full state-space model of their system in the form ẋ = Ax + Bu. It computes the optimal gain matrix K by iteratively solving the discrete-time Algebraic Riccati Equation (ARE) until convergence.

Parameters

A

The state matrix.

B

The input matrix.

Q

The state cost matrix.

R

The control cost matrix.

dt

The time step for the discrete-time model (your loop time)

maxIter

The maximum number of iterations for the DARE solver.

epsilon

The convergence tolerance for the DARE solver.