← Projects
Spacecraft flight software [PRJ-03] · 03 / 04

SmallSat flight software and ADCS

Independent project 164/164 tests · 30M fuzz execs

Zero-heap embedded C++20 spacecraft flight software and attitude control system, verified in 14,000× real-time lockstep SIL to 0.0285° nadir pointing with 164 passing tests and 30M fuzz runs.

Live Python ground monitor dashboard showing SmallSat C++20 flight software telemetry, modes, and wheel exclusion over UDP

[PRJ-03] CaptureLive Python ground monitor dashboard showing SmallSat C++20 flight software telemetry, modes, and wheel exclusion over UDP

Summary

What I built

  1. 01What

    I wrote spacecraft flight software and an Attitude Determination and Control System (ADCS) in zero-heap embedded C++20.

  2. 02How

    A deterministic 100 / 10 / 1 Hz cyclic executive runs a multiplicative extended Kalman filter (MEKF), 4-wheel control, and fault detection, isolation, and recovery (FDIR) from one YAML dictionary that generates C++ codecs, Python ground tools, and the Interface Control Document (ICD). Lockstep software-in-the-loop (SIL) runs at ~14,000× real time across 15 nominal and fault scenarios.

  3. 03Outcome

    Held 0.0285° nadir pointing (99.73rd percentile) over 2 orbits with 0 heap allocations across 62 h, 164 of 164 passing tests, and 0.8 s seized-wheel isolation recovering below 0.1° in 111 s.

Results

[PRJ-03] Measured
Nadir pointing (3σ)
0.0285°
Heap allocs / 62 h
0
Lockstep SIL speed
14,000×
  • Nadir pointing accuracy (99.73rd percentile, 2 orbits, star tracker + gyro MEKF)0.0285° (102 arcsec)
  • MEKF attitude estimation error (99.73rd percentile)0.0191° (69 arcsec)
  • Detumble from 10 deg/s to < 0.5 deg/s (magnetorquers only)3,593 s (0.63 orbits)
  • Net wheel momentum over 10 orbits: with vs without magnetic dumping< 0.35 mN·m·s vs 3.08 mN·m·s
  • Gyro dropout / stuck-at / noise burst failover to redundant gyro0.1 s / 0.3 s / 0.1 s (pointing ≤ 0.13°)
  • Reaction wheel seizure isolation and 3-wheel reallocation0.8 s isolate · 7.1° transient · < 0.1° in 111 s
  • Heap allocations across 62 h simulated flight (22.5M frames)0 (verified by nm -u + runtime operator new abort)
  • Test suite and sanitizers (GCC 16, Clang 21/23, ASan+UBSan, TSan)164 / 164 ctest · 163 / 163 ASan+UBSan · 93.65% line coverage
  • Fuzzing (libFuzzer + ASan + UBSan on COBS, packet, uplink stream)3 × 10,000,000 executions, 0 flight-code findings
  • Footprint and host base-rate CPU time (100 Hz tick, 10,000 µs budget)78 kB code · 12.3 kB static RAM · 0.37 µs mean tick
System

Architecture

  1. 01dictionary/ + tools/dictgen/

    Single YAML schema (8 telemetry packets, 17 commands, 24 events, 30 parameters) generating C++ codecs, Python ground module, ICD, and a link-checked dictionary CRC.

  2. 02fsw/sched + fsw/bus

    Deterministic 100 / 10 / 1 Hz cyclic executive with deadline monitoring and a statically sized, compile-time typed publish/subscribe message bus.

  3. 03fsw/comms

    COBS framing, CCSDS Space Packet protocol, 7-stage command validation pipeline, byte-budgeted telemetry scheduler, and stored command sequences.

  4. 04fsw/gnc

    B-dot detumble, TRIAD initialization, gyro-bias MEKF, sun pointing, quaternion feedback nadir control, 4-wheel pseudo-inverse allocation with 3-wheel reconfiguration, and magnetic momentum dumping.

  5. 05fsw/mode + fsw/fdir

    Table-driven mode manager and FDIR monitor table with watchdog, autonomous gyro failover, wheel exclusion, and SAFE mode transitions.

  6. 06sil/ + ground/

    Single-threaded bit-reproducible lockstep SIL (identical 19.5 MB telemetry hash across runs and processes) plus Python live UDP dashboard, decoder, and plot/report generator.

Design decisions

  1. D01

    Zero-heap compliance is enforced statically (nm -u ctest check rejecting operator new, malloc, __cxa_throw, __dynamic_cast, and printf) and dynamically (global operator new abort guard latched after init_complete, verified by death test).

  2. D02

    Compile-time exhaustive dispatch() breaks the build whenever a YAML command lacks a flight-software handler.

  3. D03

    Cross-language serialization tests round-trip every packet and command between C++ and Python, backed by 30M libFuzzer executions on untrusted uplink bytes.

  4. D04

    All closed-loop figures are plotted directly from decoded binary CCSDS telemetry recordings without simulator shortcuts.

Evidence

Figures

6 plots and captures. Select any figure to view it at full resolution.

[Fig. 01] Live Python ground monitor (UDP session). Captured live session commanding fsw_rt over UDP through detumble, sun-safe, nadir pointing, and reaction wheel exclusion.
[Fig. 02] Nadir pointing and MEKF estimation error (2 orbits). 99.73rd percentile pointing accuracy of 0.0285° (102 arcsec) and MEKF estimation error of 0.0191° (69 arcsec).
[Fig. 03] Reaction wheel seizure and 3-wheel reallocation. FDIR detects and excludes a seized wheel in 0.8 s, limiting the attitude transient to 7.1° and recovering below 0.1° in 111 s.
[Fig. 04] Autonomous gyro failover. Dropout, stuck-at, and noise-burst faults switch to the redundant gyro in 0.1–0.3 s without mode loss, keeping pointing within 0.13°.
[Fig. 05] 10-orbit momentum management. Magnetic momentum dumping holds net wheel angular momentum below 0.35 mN·m·s versus 3.08 mN·m·s unmanaged.
[Fig. 06] B-dot magnetic detumble. Detumble from 10 deg/s tip-off rate to under 0.5 deg/s in 0.63 orbits using magnetorquers alone.
Scope

Limits

What the model assumes and what this work does not show.

  1. L01

    Desktop POSIX host execution only; timing and footprint are unmeasured on a flight microcontroller/RTOS, and stack depth and WCET are unmeasured.

  2. L02

    Without a star tracker, the MEKF under-reports uncertainty against slowly varying geomagnetic field-model bias (mitigated via star-tracker contradiction restart instead of consider-state filtering).

  3. L03

    Dual-gyro bias jump is flagged (GYRO_DISAGREE) and not isolated (no 3-sensor majority); sun sensor and star tracker monitors are omitted.

  4. L04

    CCSDS Space Packets + CRC only (no TM/TC transfer frames, COP-1, FEC, or command authentication); PARAM_SAVE runs inline in a 10 Hz task.

Run it

Reproduce

Run the tests and regenerate every figure from the repository.

$ cmake --preset release
$ cmake --build --preset release
$ ctest --preset release
$ build/release/apps/sil_run scenarios/06_wheel_seizure.scn --record seizure.tlm
Next project · 04 / 04

Redundant flight computer (Rust)