Open Source Robotics

A curated collection of high-quality open source robotics projects, tools, and software to propel the robotics community forward.

Linear-Quadratic Regulator

  • Also called: LQR, linear quadratic regulator
  • Category: Control › Feedback control
  • Tags: optimal-control, feedback-control, state-space, riccati-equation, stabilization

An optimal feedback controller for linear systems with quadratic state and input costs, whose solution is a gain matrix found from a Riccati equation.

Definition

A linear-quadratic regulator (LQR) finds the feedback law that minimizes a quadratic cost for a system with linear dynamics. In discrete time the dynamics are x_{k+1} = A x_k + B u_k and the cost is the sum over time of xᵀQx + uᵀRu, where Q weights state error and R weights control effort. The optimal control is linear state feedback, u = −Kx, and the gain K follows from the Riccati equation: a backward recursion for a finite horizon, or the algebraic Riccati equation for an infinite horizon. Kalman formulated the problem in this form in 1960, and LQR remains one of the foundations of modern control.

In practice, engineers choose Q and R rather than placing poles directly. Larger entries in Q make the controller fight harder against errors in those states; larger R makes it use less actuator effort. Bryson's rule, which sets each diagonal weight to one over the square of the largest acceptable value, is a common starting point. With full state feedback, continuous-time LQR has guaranteed robustness margins, including at least 60 degrees of phase margin in each input channel. These guarantees do not carry over when the state is estimated by an observer; combining LQR with a Kalman filter gives LQG control, which is optimal for Gaussian noise but has no guaranteed margins.

Most robots are nonlinear, so LQR is applied to a linearization. Linearizing around an equilibrium, such as an inverted pendulum upright or a quadrotor hovering, gives a controller that works within a region of attraction around that point. Linearizing along a trajectory gives time-varying LQR, and repeating the process around improved trajectories leads to iterative LQR and differential dynamic programming. LQR does not handle constraints such as torque limits; model predictive control adds them by solving a constrained optimization online, and an unconstrained linear MPC with quadratic cost and a long enough horizon reproduces the LQR gain. Many MPC designs also use the LQR cost-to-go as their terminal cost.

Why it matters

LQR gives a principled way to design multi-input feedback controllers from a model and two weight matrices, with stability guarantees for the linearized system. It is the starting point for trajectory tracking, balance control and much of optimal and predictive control.

Key applications

  • Balance control for inverted pendulums, wheeled balancers and humanoids
  • Hover and attitude stabilization for multirotors
  • Trajectory tracking with time-varying LQR
  • Terminal cost and local controller in model predictive control
  • Stabilizing controllers for iterative trajectory optimization

In practice

A team building a two-wheeled balancing robot models it as a cart with an inverted pendulum and linearizes the dynamics around the upright position, giving A and B matrices for pitch, pitch rate, wheel position and wheel velocity. They set Q to penalize pitch heavily and wheel position lightly, choose R from the motor torque limit with Bryson's rule, and compute K with a discrete-time Riccati solver at the 200 Hz control rate. In testing, the robot balances but the motors saturate after a strong push, so they increase R until commands stay within limits for expected disturbances. A state estimator fuses IMU and encoder data to provide the full state the controller needs.

Common misconceptions

  • LQR handles actuator limits — it ignores constraints, so saturation must be checked separately or handled with MPC
  • LQR only works for linear robots — it is routinely applied to nonlinear systems through linearization, valid near the operating point or trajectory
  • LQR is always robust — its guaranteed margins require full state feedback; with an observer, as in LQG, robustness must be checked
  • Q and R come from physics — they are design choices that trade tracking against effort and are tuned for the task

Who should know this

  • Control engineers designing feedback controllers
  • Legged, balancing and aerial robot developers
  • Trajectory optimization and MPC researchers
  • Robotics students learning optimal control

Related technologies

  • Riccati Equation Solvers
  • Kalman Filter
  • LQG Control
  • Iterative LQR
  • python-control and MATLAB Control System Toolbox

Related terms

  • Model Predictive Control
  • Differential dynamic programming
  • Hamilton-Jacobi-Bellman Equation (HJB)
  • Region of attraction
  • PID Controller
  • Double Integrator

Videos

  • What Is Linear Quadratic Regulator (LQR) Optimal Control? | State Space, Part 4: MATLAB
  • Linear Quadratic Regulator (LQR) Control for the Inverted Pendulum on a Cart [Control Bootcamp]: Steve Brunton

This website requires JavaScript to function properly. Please enable JavaScript to explore our collection of open source robotics projects.