I Built a Self-Balancing Robot: Three Control Loops

Brushed motors, an ESP32 and an MPU-6500 — and three control loops, each one fixing what the one before couldn’t. The angle loop (PID, 500 times a second) keeps it upright, but it rolls 27 cm away. The speed loop brings it back to a 30 cm band. The position loop brings it home within 3 cm — then it drives over Wi-Fi and jumps off a bathroom scale. Three loops, one LQR, or a neural net — which would you bet on?