From ccd020a47272bd6ebe9bdb77181a3293ceca05bd Mon Sep 17 00:00:00 2001 From: Daniel Koepping Date: Thu, 8 Oct 2026 19:18:57 -0700 Subject: [PATCH] chestnut: fix offroad alert (#39056) chestnut: fix offroad alert (cherry picked from commit 948ad05c6ceb7eed4cd18eb75f048ddd3230e3c1) --- openpilot/selfdrive/selfdrived/alerts_offroad.json | 2 +- openpilot/selfdrive/selfdrived/selfdrived.py | 3 ++- openpilot/selfdrive/ui/ui_state.py | 6 +++++- openpilot/system/hardware/chestnut/status.py | 3 +++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/openpilot/selfdrive/selfdrived/alerts_offroad.json b/openpilot/selfdrive/selfdrived/alerts_offroad.json index 8316d093b0..052cc21f92 100644 --- a/openpilot/selfdrive/selfdrived/alerts_offroad.json +++ b/openpilot/selfdrive/selfdrived/alerts_offroad.json @@ -26,7 +26,7 @@ "severity": 0 }, "Offroad_ChestnutNotDetected": { - "text": "Chestnut not detected. Check USB and 12V connections.", + "text": "Chestnut not detected. Check USB and 12V connections, then restart the car.", "severity": 0 }, "Offroad_ChestnutOverheated": { diff --git a/openpilot/selfdrive/selfdrived/selfdrived.py b/openpilot/selfdrive/selfdrived/selfdrived.py index 0a468091a7..52370f8c7f 100755 --- a/openpilot/selfdrive/selfdrived/selfdrived.py +++ b/openpilot/selfdrive/selfdrived/selfdrived.py @@ -172,6 +172,7 @@ class SelfdriveD: big_failed = big_active is False or model_unavailable or (self.big_model_active and not chestnut_present) if big_failed and not self.big_model_failed: self.events.add(EventName.bigModelFailed) + self.big_model_ready_t = time.monotonic() self.big_model_failed = big_failed # soft disable if the big model fails @@ -453,7 +454,7 @@ class SelfdriveD: # TODO: fix simulator if not SIMULATION or REPLAY: - if self.sm['modelV2'].frameDropPerc > 1: + if self.sm['modelV2'].frameDropPerc > 1 and not big_model_settling: self.events.add(EventName.modeldLagging) # Decrement personality on distance button press diff --git a/openpilot/selfdrive/ui/ui_state.py b/openpilot/selfdrive/ui/ui_state.py index 647f977677..d7035dab00 100644 --- a/openpilot/selfdrive/ui/ui_state.py +++ b/openpilot/selfdrive/ui/ui_state.py @@ -14,6 +14,7 @@ from openpilot.system.ui.lib.application import gui_app from openpilot.common.hardware import HARDWARE, PC from openpilot.common.hardware.usb import cable_connected, get_usb_state, is_chestnut_usb_id from openpilot.selfdrive.modeld.helpers import chestnut_compiled +from openpilot.selfdrive.selfdrived.alertmanager import OFFROAD_ALERTS BACKLIGHT_OFFROAD = 65 if HARDWARE.get_device_type() == "mici" else 50 PARAM_UPDATE_TIME = 1 / 5.0 @@ -90,6 +91,7 @@ class UIState: self.chestnut_compiled: bool = chestnut_compiled() self.chestnut_active: bool | None = None self.chestnut_loading: bool = False + self.chestnut_alert: bool = False self.usb_connected: bool = False self.usb_connected_ts: float | None = None self.usb_disconnected_ts: float | None = None @@ -212,7 +214,8 @@ class UIState: detected = self.sm["deviceState"].chestnutPresent if not self.started: self.chestnut_present = detected - self.chestnut_state = (ChestnutState.READY if detected and self.chestnut_compiled else + self.chestnut_state = (ChestnutState.FAILED if self.chestnut_alert else + ChestnutState.READY if detected and self.chestnut_compiled else ChestnutState.UNCOMPILED if detected else ChestnutState.DISCONNECTED) return @@ -247,6 +250,7 @@ class UIState: self.experimental_mode = self.params.get_bool("ExperimentalMode") self.chestnut_active = self.params.get("ChestnutActive") self.chestnut_loading = self.params.get_bool("ChestnutLoading") + self.chestnut_alert = any(self.params.get(k) is not None for k, a in OFFROAD_ALERTS.items() if k.startswith("Offroad_Chestnut") and a["severity"] >= 0) now = time.monotonic() if cable_connected(): self.usb_disconnected_ts = None diff --git a/openpilot/system/hardware/chestnut/status.py b/openpilot/system/hardware/chestnut/status.py index 04a3dff821..ec54f768db 100644 --- a/openpilot/system/hardware/chestnut/status.py +++ b/openpilot/system/hardware/chestnut/status.py @@ -53,6 +53,8 @@ class ChestnutStatus: if not offroad and self.usb_seen and len(devices) != 1: self.usb_failed = True + if offroad and len(devices) == 1: + self.usb_failed = False if not offroad and state is not None: powered = state.supplyVoltage >= CHESTNUT_POWERED_VOLTAGE @@ -74,6 +76,7 @@ class ChestnutStatus: self.power_unavailable = False self.power_lost = False self.power_restored = False + self.model_failed = False if state is not None: gpu_limit = GPU_TEMP_LIMIT - (TEMP_HYSTERESIS if self.overheated else 0.)