From eef84e2b305f2f778ebe15abfd2615f4e09e151d Mon Sep 17 00:00:00 2001 From: royjr Date: Sat, 25 Jul 2026 03:31:09 -0400 Subject: [PATCH] the --- openpilot/cereal/log.capnp | 1 + openpilot/common/params_keys.h | 1 + openpilot/selfdrive/selfdrived/events.py | 11 +++++++++++ openpilot/selfdrive/selfdrived/selfdrived.py | 6 +++++- openpilot/tools/wgpu/README.md | 17 +++++++++++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/openpilot/cereal/log.capnp b/openpilot/cereal/log.capnp index 1eaaa3098b..9453a43742 100644 --- a/openpilot/cereal/log.capnp +++ b/openpilot/cereal/log.capnp @@ -132,6 +132,7 @@ struct OnroadEvent @0xc4fa6047f024e718 { userBookmark @95; excessiveActuation @96; audioFeedback @97; + wgpuModeldLagging @100; soundsUnavailableDEPRECATED @47; } diff --git a/openpilot/common/params_keys.h b/openpilot/common/params_keys.h index 96ee858609..335fbd0977 100644 --- a/openpilot/common/params_keys.h +++ b/openpilot/common/params_keys.h @@ -134,6 +134,7 @@ inline static std::unordered_map keys = { {"UsbGpuPresent", {CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION, BOOL}}, {"UsbGpuCompiled", {CLEAR_ON_MANAGER_START | CLEAR_ON_OFFROAD_TRANSITION, BOOL}}, {"Version", {PERSISTENT, STRING}}, + {"WgpuBenchMode", {CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON | DEVELOPMENT_ONLY, BOOL}}, {"WgpuEnabled", {CLEAR_ON_MANAGER_START | DEVELOPMENT_ONLY, BOOL}}, // --- sunnypilot params --- // diff --git a/openpilot/selfdrive/selfdrived/events.py b/openpilot/selfdrive/selfdrived/events.py index d7eaaf70c4..3d40db9f02 100755 --- a/openpilot/selfdrive/selfdrived/events.py +++ b/openpilot/selfdrive/selfdrived/events.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import math import os +import time from openpilot.cereal import log from opendbc.car.structs import car @@ -190,6 +191,13 @@ def modeld_lagging_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubM return NormalPermanentAlert("Driving Model Lagging", f"{sm['modelV2'].frameDropPerc:.1f}% frames dropped") +def wgpu_modeld_lagging_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster, metric: bool, + soft_disable_time: int, personality) -> Alert: + model_age_ms = max(0., (time.monotonic_ns() - sm['modelV2'].timestampEof) / 1e6) + return NormalPermanentAlert("WGPU Model Lagging", + f"{model_age_ms:.0f} ms old ยท {sm['modelV2'].frameDropPerc:.1f}% frames dropped") + + def joystick_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster, metric: bool, soft_disable_time: int, personality) -> Alert: gb = sm['carControl'].actuators.accel / 4. steer = sm['carControl'].actuators.torque @@ -722,6 +730,9 @@ EVENTS: dict[int, dict[str, Alert | AlertCallbackType]] = { ET.NO_ENTRY: NoEntryAlert("Driving Model Lagging"), ET.PERMANENT: modeld_lagging_alert, }, + EventName.wgpuModeldLagging: { + ET.PERMANENT: wgpu_modeld_lagging_alert, + }, # Besides predicting the path, lane lines and lead car data the model also # predicts the current velocity and rotation speed of the car. If the model is diff --git a/openpilot/selfdrive/selfdrived/selfdrived.py b/openpilot/selfdrive/selfdrived/selfdrived.py index 2edc0bce18..4dbae9abb6 100755 --- a/openpilot/selfdrive/selfdrived/selfdrived.py +++ b/openpilot/selfdrive/selfdrived/selfdrived.py @@ -111,6 +111,8 @@ class SelfdriveD(CruiseHelper): self.is_metric = self.params.get_bool("IsMetric") self.is_ldw_enabled = self.params.get_bool("IsLdwEnabled") self.disengage_on_accelerator = self.params.get_bool("DisengageOnAccelerator") + self.wgpu_enabled = self.params.get_bool("WgpuEnabled") + self.wgpu_bench_mode = self.params.get_bool("WgpuBenchMode") car_recognized = self.CP.brand != 'mock' @@ -469,7 +471,7 @@ class SelfdriveD(CruiseHelper): # TODO: fix simulator if not SIMULATION or REPLAY: if self.sm['modelV2'].frameDropPerc > 1: - self.events.add(EventName.modeldLagging) + self.events.add(EventName.wgpuModeldLagging if self.wgpu_enabled and self.wgpu_bench_mode else EventName.modeldLagging) # mute canBusMissing event if in Park, as it sometimes may trigger a false alarm with MADS in Paused state if CS.gearShifter == car.CarState.GearShifter.park and self.mads.enabled: @@ -625,6 +627,8 @@ class SelfdriveD(CruiseHelper): self.is_metric = self.params.get_bool("IsMetric") self.is_ldw_enabled = self.params.get_bool("IsLdwEnabled") self.disengage_on_accelerator = self.params.get_bool("DisengageOnAccelerator") + self.wgpu_enabled = self.params.get_bool("WgpuEnabled") + self.wgpu_bench_mode = self.params.get_bool("WgpuBenchMode") self.experimental_mode = self.params.get_bool("ExperimentalMode") and self.CP.openpilotLongitudinalControl self.personality = self.params.get("LongitudinalPersonality", return_default=True) diff --git a/openpilot/tools/wgpu/README.md b/openpilot/tools/wgpu/README.md index 08b5dc3605..89892913d0 100644 --- a/openpilot/tools/wgpu/README.md +++ b/openpilot/tools/wgpu/README.md @@ -57,3 +57,20 @@ Add `--big-model` after `COMMA_IP` to use the locally compiled big model. The first remote `carParams` packet can take up to 50 seconds. Stop either side with Ctrl+C. Stop the device helper before changing branches or rebooting. + +For stationary bench testing only, model lag can be changed from a blocking +event to a live warning showing model age and dropped frames. After ignition is +on and manager is running, enable the temporary override on the device: + +```sh +cd /data/openpilot +python3 -c 'from openpilot.common.params import Params; Params().put_bool("WgpuBenchMode", True)' +``` + +The override requires `WgpuEnabled` and clears on manager restart or the next +ignition-on transition. Disable it immediately with: + +```sh +cd /data/openpilot +python3 -c 'from openpilot.common.params import Params; Params().remove("WgpuBenchMode")' +```