portal: live lateral steering graph for phones (/lateral) - #164
Closed
ghbarker wants to merge 2 commits into
Closed
Conversation
The MICI lateral debug screen is too small for more than a gut feeling. The portal now serves the same signals to any phone on the device hotspot/LAN: - /lateral — self-contained page: desired vs actual steering angle on a rolling 12 s canvas (autoscaled symmetric about zero, 1-2-5 grid ladder at any scale), mph / lateral-active / live error / factors readouts, tap-anywhere pause, and a screen wake-lock. View-only by design — adjustments stay on device menus. Samples beyond +/-600 degrees (past any physical wheel) are dropped at ingest so a CAN glitch or replay seam can never blow the scale. - /api/lateral/stream — 20 Hz SSE. A singleton reader (realtime/lateral_stream) owns a SubMaster on carState/carControl/controllerStateBP, starts on the first watcher and stops after 10 s idle, so the portal costs nothing while nobody is looking. Messaging imports lazily, matching log_streamer. Fields owned by other branches (the auto-cal status string) are read defensively — a dash on the page instead of a dead stream on schemas without them. - /api/lateral joins the onroad allowlist — watching while driving is the point. Measured on a replay-fed rig: metronomic 20 fps (50 +/- 1 ms gaps, zero drops over 500+ frames), 12 ms median capture-to-client, ~4% of one CPU core while streaming and zero while idle. Confirmed working on-car from a phone. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
Closing — the /lateral phone graph never became reliable on-car (repeated disengages traced to portal spawn CPU spikes) and has been removed entirely. The on-device battery gauges in #161 cover the same need without a network path. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Standalone — no dependency on the other open Ford branches (cross-branch telemetry fields are read defensively).
The evidence that motivated this
bp_portal, the Web Routes Server) that phones on the hotspot reach today for route browsing and video — long-lived streaming connections included. The gap wasn't infrastructure; it was one page and one endpoint.Why the fix is shaped this way
/lateralis a single self-contained HTML file (no SPA build, no external assets — the device is offline);/api/lateral/streamis Server-Sent Events, which needs no client library and reconnects natively.carState,carControl,controllerStateBP); it starts on the first connected phone and shuts down 10 s after the last one leaves. Messaging is imported lazily, same pattern as the portal's log streamer./api/lateraljoins the GET allowlist alongside status/params. It's a read-only telemetry stream.The evidence afterwards
What each change is
bluepilot/backend/realtime/lateral_stream.py: the singleton reader + SSE writer (start-on-demand, idle stop, keepalive frames, per-client threads on the portal's existing ThreadingHTTPServer).bluepilot/web/public/lateral.html: the page — rolling 12 s canvas of desired vs actual steering angle, autoscaled symmetric about zero; mph / lateral-active / live-error / factors readouts and the auto-cal status line; tap-anywhere pause; screen wake-lock; auto-reconnect with an explicit "waiting for data…" veil so a stale trace is never presented as live.bluepilot/backend/bp_portal.py: two GET routes and one onroad-allowlist entry.docs/lateral-phone-graph.md: driver-facing guide (enable the toggle, join the hotspot, openhttp://192.168.43.1:8088/lateral).Test it yourself
http://192.168.43.1:8088/lateral. The graph should be live within a couple of seconds of the first frame./tmp/bp_portal.log: "lateral feed: reader stopped (idle)" ~10 s later.Risks / limits
🤖 Generated with Claude Code