Left Half-Plane
Game 01 · state feedback · Lyapunov

Stable is Still

Four numbers hold a pole upright. Gusts arrive on today's schedule and grow until something gives. The motor saturates and drains a battery. Keep it still, cheaply.

world runs today 0best today Riccati par
Where you stand today

The controller is u = kθθ + kωθ̇ + kxx + kv, nothing more. The cost is J = ∫(10θ² + x² + ½(u/umax)²) dt over thirty seconds, with umax = 20 N, plus five per second spent on the floor. Riccati par is the LQR gain for the nominal model, run in today's world. It can be beaten, because the world has an actuator delay the model does not know about, and a motor that saturates. The position gain pushes the cart toward its drift, on purpose. Read on for why.

What is going on

Feedback in four numbers

The controller measures four things: where the cart is, how fast it moves, how far the pole leans, and how fast it is falling. It multiplies each by a number and adds them up. That sum is the force on the cart. Nothing about pendulums appears in the controller; the physics is entirely in the choice of the four numbers. Choosing them is the design, and it is the whole of the game.

u = kθ θ + kω θ̇ + kx x + kvlinear state feedback: the force is a weighted sum of the state

Too little lean gain and the pole falls. Too much and the controller fights the sensor noise, burns the battery, and, with the delay, starts to oscillate. The right amount is not the most. That is the first lesson of every control course, and the one the sliders teach fastest.

Why the position gain pushes the wrong way

To move the cart to the left, the pole must first lean to the left, and the only way to lean it left is to push the cart to the right for a moment. So the position term has the same sign as the lean term: when the cart drifts right, the controller pushes it further right, the pole tips left, and the lean gain then drives the whole thing home. A pendulum has to lean before it can travel. Every balancing robot, from a Segway to a two-wheeled delivery bot, does exactly this, and it feels wrong until you see it.

The ellipses in the corner

The small plot shows the pole's angle against its angular rate. The nested ellipses are the level sets of a function V that is zero at the balanced state and grows in every direction, like a bowl. Lyapunov's idea, from 1892, is that you need not solve the motion at all: if V decreases along every trajectory, every trajectory ends at the bottom of the bowl. Watch the dot after a gust. It must keep crossing the ellipses inward. That is what stability looks like.

∀x ≠ 0 : V(x) > 0 , V̇(x) < 0a positive bowl that only ever goes down means the origin is asymptotically stable

What Riccati does

For a linear model with a quadratic cost like the one above, the best four numbers are known exactly. You write down how much you dislike lean, drift and effort, solve an equation named after Riccati, and out come the gains. That is the linear quadratic regulator, and its result is the par line. But the real cart has a delay in its motor and a limit on its force, and neither appears in the model. The best answer for the model is not the best answer for the world. The gap between them is where you play.