বাতাস Air, mission 1 of 4, after-action report

Hold a rocket upright

State has to live somewhere. And units are part of the gain.

SG90 servoSG90 servoMPU6050: accel + gyronozzle on a 2-axis gimbalestimate = 0.96 (estimate + gyro·dt) + 0.04 accelbug: estimate declared fresh each call so 'estimate' on the right is garbage
Explanatory diagram. Scroll sideways on a narrow screen.

The mission

The rocket stands on a gimbal: two hobby servos tilt the nozzle to push the body back upright. Every loop reads the IMU, estimates the tilt and corrects the nozzle. He wrote it in 2024.

What happened

A 2024 thrust-vector-control gimbal: an MPU6050 and two SG90 servos, PID on the tilt. Read again in 2026.

The wobble grows with every swing. When an error grows instead of dying out, the loop is feeding it.

What I believed

v1 fuses gyro and accelerometer with a complementary filter (0.96 / 0.04).

  • Turn up P. It isn't pushing hard enough. More gain made it swing faster. Before tuning how hard a controller pushes, check what it's being fed.
  • Filter the accelerometer harder. It's noise. Smoothing didn't help. The noise wasn't the cause; the estimate itself was wrong on every cycle.

What was true

Each call creates a new uninitialized local angleX, rather than retaining the previous estimate. V2 separates X and Y loops but uses accelerometer-only angles. Its I and D gains use milliseconds, so their numerical values cannot be copied unchanged into a seconds-based loop. Servo commands are clamped; the error integrals are not.

Try it yourself

The 2024 estimator, with and without memorypick an estimator, drag the gyro weight

Loading the diagram. It needs JavaScript; the text around it says the same thing in words.

The fix

Keep the filter's state outside the loop, and write dt in seconds: the integral and derivative had been carrying a factor of a thousand in milliseconds. A filter with no memory isn't a filter.

Evidence: gist v1 (2024-09-12), gist V2 (2024-09-13)

Keep doing

State has to live somewhere. And units are part of the gain.

Do differently

Persist filter state; specify time and gain units; handle a zero interval and actuator saturation.

Next report: Drive through the gate