control-lab
# ~/projects/control_lab.py
control_lab = Project(
status=Status.ACTIVE,
started=date(2026, 8, 31),
tags=["python"],
)Control theory ran through many of my electrical engineering courses at USP, from introductory control to nonlinear and digital control, with labs implementing digital controllers, and I ran more MATLAB and Simulink simulations than I can count. I’ve always been drawn to it. Magellan brought back the embedded systems and microcontrollers side of the degree; control-lab is where I go further and get back to the theory itself.
The lab takes textbook systems, with known dynamics and known gotchas, and walks each one through the full chain: model, linearize, discretize, control and estimate. Each step is derived again instead of called from a library, and built as production-shaped software, with typed configurations and reproducible runs.
How the work splits
It’s a learning repository, so the split between me and the agents matters. The modelling is mine to drive: the derivations, the conventions each system freezes before its dynamics are written, and how the work is cut into steps. Agents write and run the rest, from the integrator and the control library to tests, experiments and tooling, and walk me through the agreed model before they implement it. The line moves: sometimes I lean on the agents, sometimes I take a piece back and write it myself.
Experiments straddle the line. A test checks that the code does what it’s specified to do; an experiment asks a question of the system and answers it by marching the plant and reading what it recorded against what theory predicts. The prediction and the reading are mine, and what comes out is a finding, stated with a figure and its limits.
How it got here
The first system is a cart with an inverted pendulum. By 2026-09-04 it had its kinematics and rendering, a nonlinear model checked against an independent symbolic derivation, a fixed-step RK4 integrator written in the repository, and a linear model about the upright position, balanced with both pole placement and LQR.
Then, on 2026-10-09, I restructured the lab around the tooling and style guides I’d picked up while building Magellan, including an adaptation of TigerStyle. The experiments now run headless, with marimo notebooks in front of them. I never liked Jupyter notebooks; marimo’s look fine for now, and I’m still experimenting with them.
What’s next
The cart-pole still has sampled control ahead, where the controller runs at a coarse rate and my digital control coursework finally pays off, then estimation from noisy measurements, robustness and swing-up. More textbook systems follow once the cart-pole is done.