lqr
Generic Linear-quadratic regultar (LQR) controller in Rust heavily optimized with nalgebra. This can be used as a feedback controller/ trajectory tracker for all kinds of dynamical systems and has been real-world tested with cars and quadcopters.
Minimal example
Controls a car with a simple kinematic bicycle model
// Define state
let x = 2.0;
let y = 2.0;
let theta = 0.34;
let v = 3.0;
// Define controls
let delta = 0.0;
let acc = 0.0;
// Model parameters
let l = 2.0; // wheelbase
// compute matrices for the LQR controller
let a = new;
let b = new;
let q = identity;
let r = identity;
let mut controller = new?;
controller.compute_gain?;
// Set states for the optimal control computation
let current_state = new;
let desired_state = new;
let u_feedforward = new;
let u_feedback = controller.compute_optimal_controls?;
let u = u_feedforward + u_feedback;