A DIY rotary inverted pendulum you can print, solder, and train at home — for about £20 in parts. It's an open, hackable take on the rigs you'd usually buy from a lab-equipment vendor (Quanser's QUBE Servo 2 lists at around £4,500). The pendulum balances itself with a reinforcement-learning policy trained in simulation, fine-tuned on the real hardware, and quantised to run on an Arduino Nano.
| Directory | Contents |
|---|---|
meshes/, urdf/ |
3D-printable STLs and the URDF model (single source of truth for pendulum geometry) |
diagrams/ |
Wiring diagrams and component photos |
RotaryInvertedPendulum-arduino/ |
Firmware — low-level server, hand-tuned PID, on-device RL controller |
RotaryInvertedPendulum-python/ |
Sim env, SAC training, system identification, real-hardware bridge, distillation and int8 export |
RotaryInvertedPendulum-julia/ |
MPC/LQR exploration and MeshCat visualisation |
docs/ |
Build runbook, BOM, electronics design, RL stack documentation |
- Build one —
docs/BOM.md,docs/electronics_design.md,docs/end_to_end_runbook.md - Train a policy —
RotaryInvertedPendulum-python/README.mdwalks through the simulation and training pipeline - Understand the RL stack —
docs/rl_transitions.md,docs/domain_randomization.md,docs/transport_delay.md,docs/quantisation.md,docs/sysid_runbook.md
DIY kits run $100–$200 on AliExpress; the Quanser QUBE Servo 2 mentioned above is around £4,500.
- Desktop Inverted Pendulum, build-its-inprogress (full series)
- Furuta pendulum, dagor.dev
- The Rotary Control Lab — Quanser brochure (PDF)
- Survey paper, Trans. Inst. Meas. Control
- Video builds: [1], [2], [3]
I would like to thank the following people for their contributions to this project:
- Joe for suggesting I try reinforcement learning with Stable Baselines 3, which kicked off the learned-control parts of this project.
- Mykha for early discussions about this project over a beer in the park.
- André, Rafael, and Vlad for technical discussions, feedback, and support.
- Vivek for his invaluable help and feedback on the electronics of the system.
- 心诺 (Xinnuo) for her company and support while working on this project.
Finally, I would like to thank the open-source community in general for providing the tools and resources that have also helped make this project possible.