MPC/CBF Playground: safe control in your browser
I built a small interactive playground to experiment with safety-critical control: MPC/CBF Playground.
A unicycle robot drives to a goal while avoiding circular obstacles that you can drag around. You can switch between four controllers and compare them live:
- Go-to-goal: a nominal controller that ignores obstacles (the unsafe baseline).
- Go-to-goal + HOCBF: the same controller passed through a high-order control barrier function safety filter, solved as a tiny QP at every step.
- NMPC-CBF: a short-horizon nonlinear MPC with the barrier constraints embedded, showing the predicted trajectory and the solve time.
- Amortized QP: a learned policy, trained offline in JAX against an NMPC oracle, that runs in well under a millisecond.
Everything runs client-side, so there is nothing to install. Tweak the parameters, move the obstacles, and watch the barrier value h(x) stay non-negative (or not).
In upcoming posts I’ll go through the math behind each layer in more detail.