The robot's sideways balance is reduced to the classic linear-inverted-pendulum model: the center of mass tips about whichever foot is currently on the ground, accelerating away from that support point. Every stance the controller must choose where to plant the next foot — that single choice is the entire control problem.
com_accel = (g / h) · (com_x − foot_x)
capture_x = com_x + com_vx · sqrt(h / g)
The reactive controller only looks at the current position error: it plants the next foot a small proportional distance from center, blind to how fast the robot is already moving sideways. A sudden push barely changes position in the first instant, so the reactive foot placement under-reacts — velocity keeps building until a later step overshoots the safe foot-placement limit and the robot tips over.
The MPC controller solves a short receding-horizon plan every step: it projects the capture point (where the center of mass will be with zero velocity) forward using the current position and velocity, then spreads the correction across the horizon length instead of demanding it all in one stride — respecting the same maximum foot-placement limit. A longer horizon spreads a big disturbance over more steps, so each individual foot placement stays inside the physical limit even when the push is large, while a horizon of 1 step degenerates back to the same instant-only correction as the reactive controller.
- Prediction horizon — how many future steps the MPC plans over before re-solving; watch the ghost trail lengthen and the recovery smooth out.
- Disturbance strength — the lateral velocity kick applied by the push button; small pushes recover under either controller, large ones expose the reactive controller's blind spot.
- Random pushes — fires an unpredictable shove every couple of seconds so you can watch each controller's steady-state hit rate.
Real-world relevance: this is a simplified version of the capture-point / MPC push-recovery strategies used on real quadrupeds and bipeds (e.g. ANYmal, Cassie) — the receding-horizon re-solve at every control tick is exactly what lets modern legged robots absorb a kick or a missed foothold that a purely reactive PID loop would fall over from.