control//controller design//LQR

The LQR, linear quadratic regulator, is a state-feedback controller whose gain minimizes a weighted sum of state error and actuator effort over an infinite horizon, and it is how aerospace and mechatronics engineers turn *how much do I care about each error and each newton* into gains for a coupled system. Instead of choosing where the closed-loop poles go (pole placement), you write a price list and the method places them. It minimizes


The LQR, linear quadratic regulator, is a state-feedback controller whose gain minimizes a weighted sum of state error and actuator effort over an infinite horizon, and it is how aerospace and mechatronics engineers turn how much do I care about each error and each newton into gains for a coupled system. Instead of choosing where the closed-loop poles go (pole placement), you write a price list and the method places them. It minimizes

J=∫0∞(xTQx+uTRu)dt,J=\int_0^{\infty}\left(x^{\mathsf T}Qx+u^{\mathsf T}Ru\right)dt,J=∫0∞​(xTQx+uTRu)dt,

where QQQ prices each state's deviation and RRR each input's effort. The answer is a constant gain, u=−Kxu=-Kxu=−Kx with K=R−1BTPK=R^{-1}B^{\mathsf T}PK=R−1BTP, and PPP comes from the algebraic Riccati equation, one line in Python. Only the ratio between QQQ and RRR matters: multiply both by ten and KKK does not change. A first set of weights comes from Bryson's rule.

On the lateral axis of a small drone (inertia 0.015 kg\cdotpm20.015\ \text{kg·m}^20.015 kg\cdotpm2), accepting 10 cm of position, 0.5 m/s, 10° and 90°/s against 0.5 N·m of torque, the LQR returns K≈[5.0; 2.6; 5.8; 0.53]K\approx[5.0;,2.6;,5.8;,0.53]K≈[5.0;2.6;5.8;0.53] and poles at −18.7-18.7−18.7, −9.6-9.6−9.6 and −3.4±2.6j-3.4\pm2.6j−3.4±2.6j. After a 1 m step it settles to 2 cm in about a second, but in the first instant it asks for 5 N·m, ten times the acceptable torque, and tilts 38°.

K lateral4.83, 2.41, 5.52, 0.51 max tilt15° error in 6 m/s wind, LQR / PID0.19 / 0.06 m An LQR designed at hover flies a nonlinear planar drone from (−3, 2) m to (2.5, 3.2) m, tilting at most 15° and ending under 0.01 m off. In 6 m/s of wind the LQR, with no integral state, holds 0.19 m downwind; the cascaded PID, whose integral absorbs the push, ends 0.06 m off after 25 s. With the right motor at 70 % the LQR sits 0.14 m off; the adaptive term estimates the motor at 70 % and brings it to under 0.01 m.

Tap targets and raise the aggressiveness, then raise the wind: with no integral state the LQR settles off the target while the cascaded PID returns to it.

The LQR ignores limits. Its command grows in proportion to the error, so large steps saturate the motors and take the linear model past where it was valid; limits belong to MPC, which equals the LQR when no constraint is active.

With the state measured perfectly and in continuous time, it guarantees at each input a gain margin from 1/2 to infinity and at least 60° of phase margin. The small print matters: with an estimator in the loop those guarantees vanish (LQG).

It has no integrator. Like a proportional controller it cannot cancel a constant push such as wind; the fix is to add the integral of the position error as an extra state and weight it.

In flight the discrete LQR (ct.dlqr, computed offline for the loop's sampling period) is a matrix-vector product, as cheap as a PID. The expensive part is the model: the gains are only as good as AAA and BBB, which come from the drone's physics plus identification of mass, inertia and thrust constant. It is also the linear-quadratic case of the Bellman equation, and its Riccati equation is the Kalman filter's read backward (estimation-control duality).