Skip to content

Add an onroad export hook for an optional plugin - #4

Draft
RhynoTech wants to merge 1 commit into
masterfrom
onroad-export-hook
Draft

RhynoTech wants to merge 1 commit into
masterfrom
onroad-export-hook

Conversation

@RhynoTech

@RhynoTech RhynoTech commented Nov 28, 2026 •

Copy link
Copy Markdown

An extension point for apps that show the onroad screen somewhere else, such as a phone or a car's head unit. Today such an app has to patch ui_state.py and the road views at install time. With this hook it installs one plugin file and leaves sunnypilot's code alone.

This replaces #2, which was made against staging.

What it adds

  • selfdrive/ui/sunnypilot/onroad_export.py: loads an optional plugin from /data/onroad_export/plugin.py on the first UI update, if that file exists.
    • No plugin: every call returns at once.
    • A plugin defines any of publish(ui_state), set_onroad_camera(**kwargs) and set_onroad_projection(**kwargs).
    • A failing plugin: one that fails to load or raises is logged with cloudlog and dropped until the UI restarts, so it can't break the UI.
  • Three calls, all additions:
    • UIState.update: onroad_export.publish(self), after UIStateSP.update.
    • Both road views, after the camera renders: set_onroad_camera(active_camera, wide_camera_available).
    • Both road views, after set_transform: set_onroad_projection(ui_state, active_camera, content_rect, video_frame_matrix, model_transform, camera_offset), the values the model renderer draws with.

No line of existing code changes. That's on purpose, so apps that patch these files today keep working while they move to the hook.

Cost

Nothing new on the message bus and no new subscribers. Without a plugin, each call is a module-level check that returns immediately.

Tests

selfdrive/ui/sunnypilot/tests/test_onroad_export.py covers four cases: no plugin, a plugin receiving the calls, a plugin that fails to load, and a plugin that raises.

Also rendered headless on the comma four and comma 3X onroad screens with a recording plugin installed:

  • the screens draw as before;
  • the plugin received all three calls on every frame, with the arguments above.

ruff with the repository's config passes.

CI

Static analysis, unit tests and docs pass. Process replay fails for a reason that comes from upstream, not this change. Every process's output matches the reference except one sanity check: plannerd's jerk_rms on route regenB328FF8BA0A|2025-04-08--22-57-45--0 is 0.15746, over its 0.15 limit (check_jerk_rms, added in openpilot #39286, Nov 12). This PR doesn't touch plannerd. sunnypilot master fails the same step: its latest run (#4772, 55b3192) shows exit code 1 on process replay. The workflow lets that step fail on master only (continue-on-error: ${{ github.ref == 'refs/heads/master' }}), so it shows red only on pull requests.


Generated by Claude Code

@github-actions github-actions Bot added the ui label Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Process replay diff report

Replays driving segments through this PR and compares the behavior to master.
Please review any changes carefully to ensure they are expected.

✅ 0 changed, 80 passed, 0 errors

UIState.update and both road views call onroad_export, which loads an
optional plugin from /data/onroad_export/plugin.py and passes it the UI
state, the camera shown and the road projection. Without a plugin every
call returns at once; a plugin that fails is logged and dropped.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant