Inferensys

Glossary

Linear Quadratic Regulator (LQR)

An optimal control technique that computes a state-feedback gain matrix by minimizing a quadratic cost function for linear dynamical systems, often used for trajectory stabilization.
Developer building agentic RAG system, retrieval pipeline diagram on laptop, technical workspace with notes.
OPTIMAL CONTROL

What is Linear Quadratic Regulator (LQR)?

An optimal control technique that computes a state-feedback gain matrix by minimizing a quadratic cost function for linear dynamical systems, often used for trajectory stabilization.

A Linear Quadratic Regulator (LQR) is an optimal control algorithm that computes a static state-feedback gain matrix to drive a linear dynamical system to a desired state while minimizing a quadratic cost function. The cost function penalizes both state deviations and control effort, yielding a controller that balances performance against actuator energy expenditure.

LQR solves the continuous-time Algebraic Riccati Equation (ARE) to produce a gain matrix that guarantees closed-loop stability for controllable systems. In robotics, LQR is frequently employed for trajectory stabilization, where it linearizes nonlinear dynamics around a nominal path and computes corrective control inputs to reject disturbances and maintain tracking accuracy.

Optimal Control Fundamentals

Key Properties of LQR

The Linear Quadratic Regulator (LQR) is defined by a set of mathematical properties that guarantee stability, optimality, and robustness. These properties make it the foundational algorithm for trajectory stabilization in high-dimensional robotic systems.

01

Guaranteed Stability Margins

A critical property of the infinite-horizon LQR is its inherent robustness to gain and phase variations. For single-input systems, the LQR guarantees a gain margin of (−6 dB, ∞) and a phase margin of ±60°. This means the system remains stable even if the actuator output is halved or the input phase shifts significantly. This robustness arises from the return difference inequality of the optimal Kalman gain K, making LQR superior to pole placement for physical systems with unmodeled actuator dynamics.

±60°
Phase Margin
∞ dB
Upper Gain Margin
02

Quadratic Cost Minimization

LQR solves the optimization problem of minimizing a quadratic cost function J = ∫(xᵀQx + uᵀRu) dt. The state weighting matrix Q penalizes deviations from the desired trajectory, while the control weighting matrix R penalizes actuator effort. The solution yields a linear state-feedback law u = −Kx, where the optimal gain matrix K = R⁻¹BᵀP. The matrix P is found by solving the Continuous-time Algebraic Riccati Equation (CARE): AᵀP + PA − PBR⁻¹BᵀP + Q = 0.

P = Pᵀ > 0
Riccati Solution
04

Algebraic Riccati Equation Solution

The core computational step in LQR is solving the Algebraic Riccati Equation (ARE). For high-dimensional systems, direct numerical solvers are used:

  • Hamiltonian matrix method: Construct a 2n×2n matrix and compute its stable invariant subspace
  • Schur decomposition: Numerically stable approach that avoids matrix inversion errors
  • Iterative methods: Kleinman's algorithm solves a sequence of Lyapunov equations Modern libraries like SLICOT and ControlSystems.jl provide optimized ARE solvers for systems with hundreds of states.
05

Time-Varying LQR for Trajectory Tracking

For tracking a finite-horizon trajectory, the time-varying LQR solves the Differential Riccati Equation backward in time from a terminal condition P(t_f) = Q_f. This produces a time-dependent gain matrix K(t) that optimally balances tracking error and control effort at each instant. This is essential for robotic tasks like pick-and-place operations where the final pose accuracy is critical. The backward integration naturally yields a feedforward term that compensates for the reference dynamics.

P(t_f) = Q_f
Terminal Condition
06

Controllability and Observability Requirements

LQR requires the pair (A, B) to be stabilizable to guarantee a finite solution to the Riccati equation. Full controllability ensures the Riccati solution P is positive definite. Key conditions:

  • Controllability matrix [B, AB, A²B, ..., Aⁿ⁻¹B] must have full row rank
  • Uncontrollable modes must be stable (have negative real parts)
  • Q must be positive semi-definite and R must be positive definite If these conditions fail, the ARE may have no stabilizing solution, and the closed-loop system will be unstable.
OPTIMAL CONTROL COMPARISON

LQR vs. Model Predictive Control (MPC)

Comparing the unconstrained infinite-horizon linear quadratic regulator against the constrained receding-horizon model predictive control strategy for trajectory stabilization and industrial robotics applications.

FeatureLinear Quadratic Regulator (LQR)Model Predictive Control (MPC)

Control Horizon

Infinite horizon (steady-state solution)

Finite receding horizon (N steps)

Constraint Handling

Online Computation

Matrix multiplication (O(n³) offline)

Quadratic programming solve per timestep

State Feedback Law

Explicit gain matrix K (u = -Kx)

Implicit via optimization (no closed-form gain)

Handles Nonlinear Dynamics

Typical Update Rate

< 1 ms

1-100 ms

Preview of Reference Trajectory

Stability Guarantee

Infinite-horizon LQR is globally asymptotically stable for stabilizable systems

Requires terminal cost/constraint design for recursive feasibility

Optimal Control in Motion

LQR Applications in Robotics

The Linear Quadratic Regulator (LQR) is a foundational optimal control technique that computes a state-feedback gain matrix by minimizing a quadratic cost function. In robotics, it provides mathematically elegant solutions for trajectory stabilization, balance control, and precision manipulation.

01

Trajectory Tracking Stabilization

LQR excels at stabilizing a robot around a nominal trajectory. Given a pre-planned path from a sampling-based planner like RRT*, LQR computes time-varying feedback gains that correct deviations caused by disturbances or modeling errors.

  • Linearizes nonlinear dynamics around the reference trajectory at each timestep
  • Produces a time-varying LQR (TVLQR) controller that minimizes a running cost on state error and control effort
  • Commonly used in quadrotor aggressive maneuvering and autonomous vehicle lane-keeping
  • The Q matrix penalizes state error (e.g., position offset), while R penalizes control effort (e.g., motor torque)
< 1 ms
Typical Solve Time
02

Balance and Inverted Pendulum Control

LQR is the classical solution for stabilizing inherently unstable systems like the cart-pole, Segway-style robots, and bipedal walking robots. The controller continuously computes corrective forces to keep the system upright.

  • The linearized dynamics of an inverted pendulum fit perfectly into the LQR framework
  • The cost function balances deviation from vertical (Q) against motor effort (R)
  • Extends naturally to Linear Quadratic Gaussian (LQG) when sensor noise is significant
  • Used in the MIT Cheetah and Boston Dynamics Atlas for dynamic balance during locomotion
03

Precision End-Effector Control

For robotic arms performing high-precision tasks like assembly, welding, or surgical manipulation, LQR provides smooth, optimal convergence to a target pose without overshoot.

  • Formulated in operational space using the end-effector Jacobian to map joint torques to Cartesian forces
  • The Q matrix heavily penalizes Tool Center Point (TCP) position error
  • Outperforms simple PID controllers when dynamic coupling between joints is significant
  • Often combined with impedance control to manage contact forces during insertion tasks
04

Autonomous Vehicle Path Following

LQR-based controllers are widely deployed in autonomous ground vehicles for smooth, stable path following. The controller minimizes both lateral offset from the reference path and steering effort.

  • Uses a dynamic bicycle model linearized around the reference path
  • The cost function penalizes cross-track error, heading error, and steering rate
  • Provides a mathematically optimal alternative to geometric controllers like Pure Pursuit
  • Implemented in the Apollo autonomous driving framework and numerous DARPA Grand Challenge entries
05

Whole-Body Control for Humanoids

Modern humanoid robots use LQR within a whole-body control (WBC) hierarchy. LQR computes optimal ground reaction forces and joint torques to track a desired center of mass trajectory while maintaining balance.

  • The linear inverted pendulum model (LIPM) provides the simplified dynamics for LQR design
  • Q penalizes Center of Mass (CoM) position and velocity errors
  • R penalizes Center of Pressure (CoP) movement, encouraging smooth weight shifts
  • Integrated with Model Predictive Control (MPC) for handling future preview information and constraints
06

LQR vs. MPC: When to Use Each

While both are optimal control methods, LQR and Model Predictive Control (MPC) serve different roles in the robotics control stack.

  • LQR: Computes an explicit, closed-form feedback policy. Best for unconstrained problems where computational speed is critical and the system is well-approximated as linear
  • MPC: Solves a numerical optimization at each timestep. Handles explicit constraints on joint limits, torque saturation, and obstacle avoidance
  • A common architecture uses MPC for high-level planning with constraints, and LQR for low-level stabilization around the MPC-generated trajectory
  • LQR provides the infinite-horizon cost-to-go used as the terminal cost in MPC formulations
LINEAR QUADRATIC REGULATOR

Frequently Asked Questions

Concise answers to the most common technical questions about the Linear Quadratic Regulator (LQR), covering its mathematical foundation, implementation, and comparison to other optimal control strategies.

A Linear Quadratic Regulator (LQR) is an optimal control strategy that computes a state-feedback gain matrix K to stabilize a linear dynamical system while minimizing a quadratic cost function that penalizes state error and control effort. The controller assumes the system dynamics are linear (ẋ = Ax + Bu) and the cost function J = ∫ (xᵀQx + uᵀRu) dt is quadratic, where Q weights state deviations and R weights control input magnitude. The optimal control law u = -Kx is derived by solving the Continuous-time Algebraic Riccati Equation (CARE): AᵀP + PA - PBR⁻¹BᵀP + Q = 0. The resulting gain matrix K = R⁻¹BᵀP provides a closed-form, globally optimal solution for the infinite-horizon problem, making LQR computationally efficient and analytically tractable compared to iterative numerical optimization methods.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.