Ahmed Doghri Logo Image
Ahmed Doghri

pendulumlab

Robot learning demos usually hide the whole story behind a simulator download. I wanted the opposite: physics, policy search, reward curve, all in plain Python. CEM moves return from -54.30 to 217.38.

pendulumlab, an inverted pendulum control benchmark

A Pendulum That Does Not Need a GPU

Most robotics repos ask you to install half a lab before you see a curve. I built pendulumlab to make the control loop small enough to audit. The state is angle and angular velocity. The action is torque. The reward is upright, smooth, and cheap.

The point is not pretending this replaces MuJoCo or Isaac Lab. The point is showing the actual structure of a control benchmark without the fog. You can read the dynamics, read the reward, run the search, and reproduce the curve in one command.

CEM Without The Theater

The policy is a linear torque controller. The optimizer is cross-entropy method: sample gain vectors, score them on the same starts, keep the elites, tighten the distribution, repeat.

I like this benchmark because every number has somewhere to live. If the controller gets better, the CSV says so. If the reward changes, the curve changes. No hidden checkpoint. No borrowed environment. No paid key.

The Number

Zero torque averages -54.30 return. A hand-tuned PD controller reaches 137.39. CEM lands at 217.38 and holds a final-window upright reward of 1.000.

4 tests pass locally and on GitHub Actions across Python 3.9, 3.11, and 3.13. The benchmark writes `artifacts/reward_curve.csv` and `artifacts/reward_curve.svg` every run.

Tools Used

Python
Physics Simulation
CEM Policy Search
Control
pytest
Ruff
GitHub Actions CI