02Sep 2024 — present
Rocket Avionics and Roll Control
A flight computer that keeps a rocket from spinning. Partway up, the board decides on its own that the moment has come, powers the canard fins and starts actively cancelling the roll — knowing which way it is pointing, how high it is and how fast it is going, all estimated on board in real time.

- Where
- MetRocketry Design Team
- Stack
- C, C++, STM32F446, FreeRTOS, Eigen, FatFs
- Built with
- Ranvir Singh
- Source
- Repository
- 10 msactuator latency
- 6flight states
- 7RTOS tasks
The control cycle
Four stages run per cycle: sense, estimate, control, actuate. Sensors go in at the top and canard deflection comes out at the bottom.
Logging and telemetry hang off the state estimate rather than sitting inside the loop, so nothing downstream can stall the part that is actually flying the rocket. A slow SD write cannot delay a fin command.
FreeRTOS runs on an STM32F446, generated out of CubeMX and built with CMake and Ninja. The attitude filter is C++ with Eigen, bridged into the C tasks, and logging goes through FatFs over SDIO.

The flight state machine
The board tracks the flight on its own, using accelerometer thresholds, timers and its own velocity estimate, and moves through six states: PAD → BOOSTER_BURNOUT → SEPARATION → SUSTAINER_IGNITION → CANARDS_ACTIVATE → DESCENT.
It detects liftoff, booster burnout, stage separation and sustainer ignition, brings the canards live for exactly the window they are needed in, then recognises descent and shuts them down again. The servo power switch is cut in every state except CANARDS_ACTIVATE, so the highest-current rail on the board is only ever energised when the fins are actually flying.

The task set
Each task pre-empts and runs the moment its input is ready. The watchdog is gated behind a heartbeat that polls every task, so a stalled estimator resets the board instead of flying it on a frozen state.
| Task | What it does |
|---|---|
| readSensor | Reads the IMU, magnetometer and barometer, and low-pass filters them. |
| launchDet | Runs the flight state machine and tells everything downstream. |
| oriEst | Quaternion EKF for roll, pitch, yaw and tilt. |
| altEst | Kalman filter fusing barometer and accelerometer for altitude and vertical velocity. |
| control | PID roll controller driving the canard servos. |
| dataStore | Snapshots telemetry and writes CSV rows to the SD card. |
| heartbeat | Refreshes the watchdog, but only once every flight task reports healthy. |
Estimation and control
Attitude comes from a quaternion EKF written in C++ with Eigen. Altitude and vertical velocity come from a separate Kalman filter fusing the barometer with the accelerometer. Roll is rotation about the long axis of the rocket, which is the estimator's yaw, and the units are pinned down across the whole codebase: Pa, mg, m, m/s, degrees.
The roll controller is PID, and it drives the fins through an aerodynamic force-to-deflection model that corrects for airspeed and air density. The same control effort produces the same roll authority on the pad and at altitude, which is what lets one set of gains work across the whole flight.

Bus architecture
The IMU gets read every control cycle and feeds the attitude estimator directly. The GPS does long UBX transactions. They sit on separate buses with separate mutexes, so the attitude estimator can never end up blocked behind a navigation transfer and the control path always runs on time.
| Bus | Device | What it carries |
|---|---|---|
| SPI1 | LSM6DSO32 IMU | Gyro and accelerometer. Feeds the EKF; the highest-priority traffic on the board. |
| SPI1 | RFM69HCW radio | Telemetry downlink. Wired and driven, not switched on yet. |
| SPI2 | MS5611 barometer | Altitude and vertical velocity for the Kalman filter. |
| SPI2 | u-blox NEO-M9N GPS | Position and velocity over UBX. Driver written, not enabled in flight builds yet. |
| I2C1 | MMC5983MA magnetometer | Heading reference and yaw correction. |
| SDIO | microSD card, 4-bit | Flight logging through FatFs, on DMA. |
| TIM3 | Two servo channels | Canard actuation, live only during CANARDS_ACTIVATE. |
Where it stands
The board is built and the firmware flies. Sensor drivers, the attitude EKF, the altitude Kalman filter, launch detection and the flight state machine, PID roll control with the aerodynamic model, and SD logging are all done and exercised. Flight logs have been pulled back off the card and gone through against what the estimator thought was happening at the time.
GPS and radio are wired and driven; turning both on in flight builds is next. A new flight computer is in design for December, carrying these lessons into it — SDIO on a single package edge this time, and controlled-impedance routing planned out from the stackup at the start. The next build cycle covers roll canards, airbrakes and a live video downlink.