LIVE TRACK MODE Pixel 10 Gemma 4 E2B Sonoma Raceway 289 Tests

Pitwall:
Real-Time AI
Race Coach
— On Device.

Move beyond the reactive post-session debrief of Garmin Catalyst or AiM Solo. Pitwall runs entirely on Pixel 10 via Termux — no cell coverage required. Sub-50ms hot-path coaching grounded in Ross Bentley's pedagogy, adapting to your skill level in real time.

<50ms Hot Path
289 Tests Pass
50 API Routes
12 Corners
Sonoma T3 · Carousel
▶ TRAIL BRAKE THROUGH FIRST APEX
LIVE
Speed
68km/h
Brake
4.2bar
Lat G
0.81g

Live Telemetry · Lap Delta

1:42.82 ▲ +0.12
SECTOR 2: ▼ −0.04 CORNER: T3A
auto_stories

Domain Expertise Layer

9 pedagogical vectors drawn from Ross Bentley's Performance Driving Illustrated. T-Rod Sonoma transcript encoded as canonical phrases. Per-corner doctrine for all 12 turns at Sonoma Raceway.

Bentley Logic 9 Vectors T-Rod Anchors
memory

Split-Brain Engine

Hot path (sonic model + RuleCoach) fires in <50ms — zero LLM calls during driving. Warm path (Gemma 4 E2B via LiteRT-LM) provides tactical depth in 2–4s. CoachArbiter holds 78% of cues. Silence is coaching.

<50ms Hot Gemma 4 E2B 78% Suppressed
shield_lock

Private & Offline

Zero cloud dependency for the core coaching loop. All telemetry persists in local DuckDB on-device. Bridge binds to 127.0.0.1 only. Optional cloud Gemini debrief sends aggregate stats only — never raw frames.

DuckDB Local Air-Gapped 127.0.0.1

Validated Cue Distribution

Sourced from 11,737 real Sonoma telemetry frames · BMW M3 E46

21.7% Silence = Doing It Right
Grip Tone — continuous pitch, always on 55.2%
Brake Approach — ascending pitch at corner entry 42.3%
Speed Delta (LSTM) — actual vs. predicted >5 km/h ~18%
Silence — straights, clean driving 21.7%
Throttle Cue 3.2%
Coast Warning 3.0%
Trail Brake 1.2%
Corner Chime 0.5%
Cues Held 78%
Total Frames 11,737

Architecture Breakdown

Hot Path · <50ms

Sonic model + RuleCoach deterministic engine. Zero LLM calls during driving. Grip tones, shift indicators, brake approach alerts. Pure TPU compute.

Files: sonic_model.py · coach_engine.py:RuleCoach

Warm Path · 2–4s

Gemma 4 E2B on-device via LiteRT-LM (MediaPipe Genai). Paddock brief & debrief. System prompt contains Bentley pedagogy + Sonoma corner doctrine.

Files: coach_engine.py:LitertCoach · gemma-4-E2B-it.litertlm

Cold Path · 8–15s (Optional)

Cloud Gemini post-session debrief. Requires GEMINI_API_KEY. Sends aggregate stats only — zero raw telemetry frames. Graceful no-op without key.

Files: pitwall_bridge.py:POST /coach/debrief

Data Flow · End-to-End

USB-CAN ADAPTER CANable Pro · slcan@500kbps RACELOGIC VBO 20Hz GPS + 3-axis IMU OBDLINK MX Brake · Throttle · RPM CAN INGEST python-can + cantools DuckDB · <5ms/frame DOMAIN EXPERTISE Ross Bentley · 9 Vectors T-Rod Sonoma Patterns 12 Corner Doctrine Skill-Level Adapter → Suppresses 78% coach_engine.py SPLIT-BRAIN ENGINE HOT <50ms · sonic_model.py WARM 2-4s · LitertCoach P0–P3 Arbiter priority queue State: OPEN→COOLDOWN→BLACKOUT Motion gate · Skill gate CoachArbiter · ADR-002 pitwall_bridge.py OUTPUT 🎧 Audio (TTS) 📱 Vue PWA HUD 📊 50 REST API 💾 DuckDB Replay PIXEL 10 · TERMUX · runit SUPERVISOR · DOZE-SAFE

Trust Gates · CoachArbiter Logic

Priority Levels

P3 Safety · P2 Technique

P1 Strategy · P0 Flavor

State Machine

OPEN → DELIVERING

→ COOLDOWN → BLACKOUT

Motion gate ACTIVE
Skill classification BEGINNER / INTER / ADV
Phase filter (entry/apex/exit) CORNER-AWARE
Cue suppression rate 78% HELD

Arbiter prevents LLM suggestions from overriding safety-critical deterministic grip tones. P0 safety always preempts any LLM output.

Latency Budget · Wall-Clock

Component Budget Source
CAN frame → DuckDB row< 5mscan_reader.py
Hot path: sonic cue< 50msADR-002
RuleCoach (in-process)< 100mscoach_engine.py
LiteRT-LM Gemma 4 E2B2–4sADR-012
Capability recompute< 200msADR-015
Cloud Gemini debrief8–15sOptional
Smoke: 8,273 frames + 50 endpoints~12ssmoke_test.py

Google Stack · On-Device First

Layer Component Model / ID Where
HotSonic ModelRule engine (no LLM)sonic_model.py
WarmLiteRT-LM + MediaPipe Genaigemma-4-E2B-it.litertlmLitertCoach
WarmPixel 10 TPU / AiCorecom.google.ai.edgevalidate_litert.py
ColdGemini Debriefgemini-2.5-flash (optional)pitwall_bridge.py
StoreDuckDB + ParquetLocal-only, no syncpitwall_bridge.py

Bentley Curriculum · Pedagogical Vectors

Vector Condition Beginner Advanced
Weight XfergLong/gLat spike"Smooth it out""Load rate exceeded"
Trail BrakeBrake >10% + gLat >0.4g"Carry brake in""Trail to apex"
CoastingNo throttle >30 km/h"Leaving time out""6.3% lap in coast"
BrakingOvershoot"Brake earlier""Compress zone 1"
LineEarly apex"Wait to turn""Deepen entry"
ThrottlePost-apex hesitation"Squeeze sooner""Verify traction"

Sonoma Corner Doctrine

12 corners · 4,258m · 49m elevation range · OSM-derived GPS centerline

Field Test: May 23, 2026 BMW M3 E46
T2 GEAR 3

Late apex hairpin. Commitment to trail brake past the apex curb separates laps.

Apex Speed52 km/h
T-Rod Anchor"Brake late"
T3 GEAR 3
The Carousel

Double-apex. Trail brake past first apex. Commitment is everything. Common mistake: rushing throttle on exit → understeer.

Apex Speed68 km/h
Landmark"The Bridge"
T3A GEAR 3

Second apex of the Carousel. Patience on throttle — exit feeds the long back straight.

Apex Speed72 km/h
T-Rod Anchor"Patience on throttle"
T6 GEAR 4

High-speed sweeper. Balance throttle through full arc. Trust the grip — coasting here loses 0.4s/lap.

Apex Speed105 km/h
DangerK-WALL BEND
T7 GEAR 3

Medium-speed, decreasing radius. Trail brake to hold mid-corner speed. Early throttle creates understeer.

Apex Speed78 km/h
Bentley VectorTrail Brake
T9–10 GEAR 3
Calamity Corner

Elevation change complicates braking. Use the curb on entry. T-Rod: "Distance is king" — don't compromise exit speed.

Apex Speed55 km/h
T-Rod Anchor"Distance is king"
T11 GEAR 3

Off-camber. Use the curb — it's there for a reason. T-Rod: "Trust the curb." Entry commitment sets up T12 exit.

Apex Speed62 km/h
T-Rod Anchor"Trust the curb"
T12 GEAR 4
Final Corner

Last corner onto the main straight. Wide entry, late apex. Maximize throttle at apex — exit speed compounds onto the straight.

Apex Speed85 km/h
PrioritySpeed Exit

Analytics Surface

50 REST endpoints · 11 post-session analysers · DuckDB local

timer Lap Times
donut_large Sector Splits
grade Corner Grades
show_chart Pedal Curves
scatter_plot G-G Diagram
speed Speed Delta
bolt Ideal Lap
route Throttle Heatmap
settings_input_component CAN Signals
trending_up Driver Evolution
gps_fixed Track Map
bar_chart Lap Distribution

Technical Stack · As Shipped

Layer Technology Details
Edge Compute Pixel 10 + Termux runit supervisor · Termux:Boot · Doze-safe via wake lock
On-Device LLM Gemma 4 E2B · LiteRT-LM MediaPipe Genai · gemma-4-E2B-it.litertlm · warm path only
CAN Ingest python-can + cantools USB-CAN adapter (CANable Pro / Macchina M2) · 29 signals · 9 messages · pitwall.dbc
Persistence DuckDB + Parquet Local-only · wide table (11 signals) + tall sink (any signal) · user-driven export
Bridge API Flask · 50 routes pitwall_bridge.py · 127.0.0.1:8765 · adb reverse tunnel for dev
Frontend Vue 3 + Vite + Tailwind GBA retro aesthetic · PWA manifest · pixel-art frames · in-progress (ADR-016)
Track Data Sonoma JSON · OSM GPS 139 KB · 12 corners · real GPS centerline · gold-standard lap · marker thumbnails
ML Models LSTM v1 + v3 Speed delta prediction · validated on 8,273 Sonoma frames
Testing pytest · smoke suite 289 passing · 0 skipped · 51 smoke assertions · virtual CAN bus (no kernel modules)

Architecture Decision Records

17 ADRs · docs/adr/index.md

ADR-002 Core

Split-Brain + Message Arbiter

Hot/warm/cold separation with priority queue. CoachArbiter holds 78% of cues.

ADR-003 LLM

Gemma 4 as Edge LLM

Gemma 4 E2B via LiteRT-LM for warm path. No cloud required for coaching loop.

ADR-005 Pedagogy

Pedagogical Vector Retrieval

9 Bentley vectors encoded as retrieval keys. Every cue traces back to curriculum.

ADR-009 Resilience

Graceful Degradation Protocol

Bridge dies → sonic_model fallback. LLM timeout → cached phrases. Network drops → Antigravity pipeline.

ADR-015 Data

Universal Telemetry Sink

Wide table (11 canonical signals) + tall sink (any signal). 54-entry OBD2 signal registry. Any car, any feed.

ADR-017 Current

Three-Tier Coach Architecture

Hot (no LLM) / Warm (Gemma 4 E2B) / Cold (optional Gemini). Audio-first with HUD fallback.

ADR-016 Frontend

USB-CAN Ingest + Vue PWA

Pivot from BLE+Flutter to USB-CAN+Vue 3. GBA retro aesthetic. Same Flask backend bridges both.

ADR-006 Sensors

Sensor Fusion · Racelogic + OBD

ASOF + lerp interpolation. Axis switching (GPS / lap-distance / signal-name). Uniform-grid resampling.

+9

More ADRs

docs/adr/index.md

Mission Lifecycle · Day at Sonoma

01
Arrive

5 MIN

Hardware pair. GET /health. USB-CAN connect.

02
Pre-Brief

2–4 MIN

Set 1–3 goals. Gemma 4 reads weather, picks focus corners.

03
Out-Lap

1 LAP

P3 safety cues only. Sonic model at 50% volume. Sensor calibrate.

04
Hot Laps

4–8 LAPS

Full co-pilot. Audio + HUD. Cue volume scales with lap-time delta to goal.

05
Cool-Down

1 LAP

Chimes only. No coaching. Driver builds mental model.

06
Debrief

5–15 MIN

POST /coach/debrief. Lap table, friction circle, corner A–F grades.

Engineering & Pedagogy Team

Team 2 · Intermediate · BMW M3 E46

HH
Hemanth HM

Tech Lead · Platform Arch

SM
Simon Margolis

Edge · Telemetry

TB
Taha Bouhsine

AGY Pipeline

VV
Vijay Vivekanand

Data Reasoning

AV
Aileen Villanueva

UX · Frontend

Acknowledgements: Ross Bentley · Performance Driving Illustrated · T-Rod Sonoma Transcript · Racelogic VBO Format · python-can · cantools · DuckDB · MediaPipe Genai · LiteRT-LM
terminal GitHub Repo description 17 ADRs api API Docs
50 endpoints
account_tree Architecture school Pedagogy
Bentley curriculum