Driver-state detection from lane keeping on a microcontroller

An int8 classifier on an Arm Cortex-M4F labels each lane-position sample as calm, alert, stressed or panic. It uses 40 multiply-accumulates per sample and 1,802 bytes of flash. A host machine fits a model of how each stretch of the route shifts lane position and sends the device one int16 correction per site.

The test that matters: does the int8 classifier make the same call as a full-precision one? On 5,000 simulated samples they agree 99.66% of the time, and both are correct about 92% of the time.

All data simulated with fixed seeds; model settings are illustrative. Write-up · Code · Dataset

Watch it work

Top: lateral offset from lane centre, mm. Middle: simulated driver state in black (0 calm, 1 alert, 2 stressed, 3 panic) and the int8 call in orange. Bottom: per-state confidence, float solid and int8 dashed.

Headline numbers

Int8 and float classifiers agree99.66% of moments
Float classifier accuracy92.34%
Int8 classifier accuracy92.40%
Panic episodes caught by int8, default noise151 of 157
False panic rate, default noise0.64% of moments

Sensor noise sweep

Accuracy and panic detection fall together for both versions as sensor noise rises

Sensor noise scaled from 0.5x to 2x, 5 seeds of 2,000 samples per level. Accuracy falls from 99.5% to 79.7% for both classifiers; int8 stays within 0.04 points of float. At default noise int8 catches 151 of 157 panic episodes, median detection delay 0 samples.

Route-model fit

Forty estimates clustered around the true values, all within 20 percent

40 simulated routes with known settings, 200 sensors each, fitted on CPU. Median error 6.1% on correlation range and 3.8% on variance scale; every fit within 20%.

Sparse solve cost

Each fit iteration factorises a sparse system. Reverse Cuthill-McKee reordering cuts the factor from 43,640 to 45,258 stored values down to 11,378, and the work from 3.88M to 174k multiply-accumulates per evaluation.

What hasn't been measured yet

GPU timings, on-device latency, and accuracy on recorded drives. The CUDA path compiles but has not been run.