ConfidenceVisual

This commit is contained in:
royjr
2026-02-11 01:14:41 -05:00
parent 1277503e7a
commit f0dba2446a
5 changed files with 36 additions and 12 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ inline static std::unordered_map<std::string, ParamKeyAttributes> keys = {
{"CarParamsPersistent", {PERSISTENT, BYTES}},
{"CarParamsPrevRoute", {PERSISTENT, BYTES}},
{"CompletedTrainingVersion", {PERSISTENT, STRING, "0"}},
{"ConfidenceBall", {PERSISTENT | BACKUP, BOOL, "0"}},
{"ConfidenceVisual", {PERSISTENT | BACKUP, INT, "0"}},
{"ControlsReady", {CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION, BOOL}},
{"CurrentBootlog", {PERSISTENT, STRING}},
{"CurrentRoute", {CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION, STRING}},
+22 -3
View File
@@ -57,7 +57,9 @@ class AugmentedRoadView(CameraView, AugmentedRoadViewSP):
self._hud_renderer = HudRenderer()
self.alert_renderer = AlertRenderer()
self.driver_state_renderer = DriverStateRenderer()
self._confidence_ball = ConfidenceBall(scale = 1.0, bar = True)
self._confidence_visual: ConfidenceBall | None = None
self._confidence_visual_mode: int = 0
# debug
self._pm = messaging.PubMaster(['uiDebug'])
@@ -106,8 +108,9 @@ class AugmentedRoadView(CameraView, AugmentedRoadViewSP):
# End clipping region
rl.end_scissor_mode()
if ui_state.confidence_ball:
self._confidence_ball.render(self._content_rect)
self._update_confidence_visual()
if self._confidence_visual is not None:
self._confidence_visual.render(self._content_rect)
# Draw colored border based on driving state
self._draw_border(rect)
@@ -239,6 +242,22 @@ class AugmentedRoadView(CameraView, AugmentedRoadViewSP):
if gui_app.sunnypilot_ui():
ui_state.reset_onroad_sleep_timer(OnroadTimerStatus.PAUSE)
def _update_confidence_visual(self):
mode = int(getattr(ui_state, "confidence_visual", 0) or 0)
# Only rebuild when the mode changes
if mode == self._confidence_visual_mode:
return
self._confidence_visual_mode = mode
if mode == 1:
self._confidence_visual = ConfidenceBall(scale=1.0, bar=False)
elif mode == 2:
self._confidence_visual = ConfidenceBall(scale=1.0, bar=True)
else:
self._confidence_visual = None
if __name__ == "__main__":
gui_app.init_window("OnRoad Camera View")
@@ -39,11 +39,6 @@ class VisualsLayout(Widget):
tr("Display steering arc on the driving screen when lateral control is enabled."),
None,
),
"ConfidenceBall": (
lambda: tr("Confidence Ball"),
tr("Display confidence ball on the driving screen."),
True,
),
"RainbowMode": (
lambda: tr("Enable Tesla Rainbow Mode"),
tr("A beautiful rainbow effect on the path the model wants to take. " +
@@ -125,10 +120,18 @@ class VisualsLayout(Widget):
button_width=350,
inline=False
)
self._confidence_visual = multiple_button_item_sp(
title=lambda: tr("Confidence Visual"),
description=lambda: tr("Display confidence ball or bar on the driving screen."),
buttons=[lambda: tr("Off"), lambda: tr("Ball"), lambda: tr("Bar")],
param="ConfidenceVisual",
inline=False
)
items = list(self._toggles.values()) + [
self._chevron_info,
self._dev_ui_info,
self._confidence_visual,
]
return items
@@ -140,6 +143,8 @@ class VisualsLayout(Widget):
self._dev_ui_info.action_item.set_selected_button(ui_state.params.get("DevUIInfo", return_default=True))
self._confidence_visual.action_item.set_selected_button(ui_state.params.get("ConfidenceVisual", return_default=True))
if ui_state.has_longitudinal_control:
self._chevron_info.set_description(tr(CHEVRON_INFO_DESCRIPTION["enabled"]))
self._chevron_info.action_item.set_selected_button(ui_state.params.get("ChevronInfo", return_default=True))
+1 -1
View File
@@ -138,7 +138,7 @@ class UIStateSP:
self.torque_bar = self.params.get_bool("TorqueBar")
self.true_v_ego_ui = self.params.get_bool("TrueVEgoUI")
self.turn_signals = self.params.get_bool("ShowTurnSignals")
self.confidence_ball = self.params.get_bool("ConfidenceBall")
self.confidence_visual = self.params.get("ConfidenceVisual")
class DeviceSP:
+2 -2
View File
@@ -182,8 +182,8 @@
"title": "Completed Training Version",
"description": ""
},
"ConfidenceBall": {
"title": "Confidence Ball",
"ConfidenceVisual": {
"title": "Confidence Visual",
"description": ""
},
"ControlsReady": {