Control law design
From PID to model predictive control and safety filters: what each method needs from the model, and what it gives back.
A control law is a rule that determines the control input based on the current state of the system.
What a control law is
In the general case a feedback law is a map
$$u = \pi(x, t), \qquad \text{or with a reference} \qquad u = \pi(x, x_d, t).$$Open-loop control computes \(u(t)\) ahead of time from the model alone without any correction. It is fine when the model is exact and nothing disturbs the system. Feedback measures the actual state and reacts, which is what allows the systme to correct the model error and disturbance. In practice most controllers combine the two: a feedforward term from a planned trajectory, plus feedback on thes error.
Design specifications usually fall into four groups, and they compete:
- Stability. Does the error go to zero, and from how far away? Local, regional, or global; asymptotic or exponential.
- Performance. Settling time, overshoot, tracking error, energy.
- Constraints. Input saturation \(u \in \mathcal{U}\), state and safety constraints \(x \in \mathcal{X}\).
- Robustness. How much model error and disturbance can the loop absorb before any of the above stops holding?
PID
A super-duper common control strategy. The model-free baseline. On a scalar error \(e = x_d - x\),
$$u = k_p e + k_i \int_0^t e(\tau)\,d\tau + k_d \dot{e}.$$Proportional acts on present error, integral removes steady-state offset caused by constant disturbances or bias, derivative adds damping. It needs no model, which is its whole appeal, and it remains the right answer for well-behaved single-input loops: motor speed, altitude hold, heading hold.
No explicit safety or constraint handling, and typically myopic.
A cascade of PID loops - fast inner loop on rate, slower outer loop on position - is still the most widely deployed architecture in robotics.
Linear quadratic regulation (LQR) is a feedback controller by solving an optimal control problem for a linear dynamical system. For
$$\dot{x}=Ax+Bu,$$the infinite-horizon LQR problem minimizes the cost
$$J=\int_0^\infty \left(x^\top Qx+u^\top Ru\right)dt,\qquad Q\succeq0,\ R\succ0.$$The matrix \(Q\) penalizes deviations of the state, while \(R\) penalizes control effort. The resulting optimal controller is a linear state-feedback law
$$u=-Kx,$$where
$$K=R^{-1}B^\top P,$$and \(P\) is the positive-semidefinite solution of the algebraic Riccati equation
$$A^\top P+PA-PBR^{-1}B^\top P+Q=0.$$Thus, rather than specifying a desired closed-loop behavior directly, LQR specifies a tradeoff between state regulation and control effort and computes the corresponding optimal feedback law.
In practice, the discrete-time formulation is often used for implementation. For tracking a time-varying reference trajectory, LQR can also be extended to a finite-horizon, time-varying form by linearizing the dynamics along the nominal trajectory and solving a Riccati equation backward in time.
When the state is not directly available and measurements are noisy, an LQR controller can be combined with a Kalman filter to estimate the state. This gives linear quadratic Gaussian (LQG) control.
For nonlinear systems, related methods such as iterative LQR (iLQR) are used.
Lyapunov design and CLF-QP
The general nonlinear tool. Find a scalar \(V(x) > 0\) that vanishes only at the target, then choose \(u\) to make it decrease. For a control-affine system,
$$\dot{V}(x,u) = \underbrace{\nabla V(x)^\top f(x)}_{L_f V(x)} + \underbrace{\nabla V(x)^\top g(x)}_{L_g V(x)} u,$$which is affine in \(u\). \(V\) is a control Lyapunov function if some admissible \(u\) can always make \(\dot V\) sufficiently negative, and the requirement
$$L_f V(x) + L_g V(x)\,u \le -\gamma\big(V(x)\big)$$is a single linear inequality in \(u\). So you can ask for the smallest input that satisfies it,
$$u^\star = \arg\min_{u \in \mathcal{U}} \ \|u - u_{\text{nom}}\|^2 \quad \text{s.t.} \quad L_f V + L_g V\,u \le -\gamma(V),$$a quadratic program solvable in microseconds. This is the CLF-QP, and it is the template for the safety machinery below. Finding \(V\) is the hard part; for mechanical systems total energy is often a good first guess, and sum-of-squares programming can search for one systematically.
Safety filters and control barrier functions
Stability and safety are different requirements. Safety is forward invariance of a set: if you start inside \(\mathcal{C} = \{x : h(x) \ge 0\}\), you never leave it. A control barrier function enforces this with the condition
$$\underbrace{L_f h(x) + L_g h(x)\,u}_{\dot{h}} \ \ge\ -\alpha\big(h(x)\big),$$for an extended class-\(\mathcal{K}\) function \(\alpha\). Far from the boundary (\(h\) large) the condition is slack; near it (\(h \to 0\)) it forces \(\dot h \ge 0\). Again affine in \(u\), so it slots into the same QP.
The modular structure is nice: any nominal controller - PID, MPC, a learned policy - can be wrapped, and the filter intervenes minimally. The open problem is the how can we verify that \(h\) is a CBF. Also, we use CBF-QP as a controller, which is myopic.
Model predictive control
Rather than using a fixed feedback law, solve an optimal control problem online at each step, apply only the first control input, and repeat the process at the next step (receding horizon).
$$\begin{aligned} \min_{u_{0:N-1}} \quad & \sum_{k=0}^{N-1} \ell(x_k, u_k) + \ell_f(x_N) \\ \text{s.t.} \quad & x_{k+1} = F(x_k, u_k), \quad x_0 = x(t), \\ & x_k \in \mathcal{X}, \quad u_k \in \mathcal{U}, \quad x_N \in \mathcal{X}_f. \end{aligned}$$Apply \(u_0\), advance one step, re-measure, re-solve. That receding horizon is what turns an open-loop optimization into feedback.
MPC is the natural choice when constraints (and input bounds) matter, because they appear explicitly in the problem.
For linear systems with convex constraints, very fast and globally optimal, with stability and recursive feasibility under appropriate conditions; for nonlinear systems and/or non-convex constraints, more computationally intensive and may be suboptimal.