From 65853f011178b7ca6154c786ce7424c1ce1d678d Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Wed, 26 Mar 2025 01:08:22 -0400 Subject: [PATCH 1/2] NNLC: Fix exact match consistency (#716) Move the exact_match calculation after updating model_path and max_similarity to ensure consistency. This prevents potential discrepancies when rechecking NN paths and enhances code maintainability. --- sunnypilot/selfdrive/controls/lib/nnlc/helpers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sunnypilot/selfdrive/controls/lib/nnlc/helpers.py b/sunnypilot/selfdrive/controls/lib/nnlc/helpers.py index 8c33fec023..c34fa435c2 100644 --- a/sunnypilot/selfdrive/controls/lib/nnlc/helpers.py +++ b/sunnypilot/selfdrive/controls/lib/nnlc/helpers.py @@ -43,12 +43,13 @@ def get_nn_model_path(CP: structs.CarParams) -> tuple[str, str, bool]: nn_candidate = car_fingerprint model_path, max_similarity = check_nn_path(nn_candidate) - exact_match = max_similarity >= 0.99 if car_fingerprint not in model_path or 0.0 <= max_similarity < 0.9: nn_candidate = car_fingerprint model_path, max_similarity = check_nn_path(nn_candidate) + exact_match = max_similarity >= 0.99 + if 0.0 <= max_similarity < 0.9: with open(TORQUE_NN_MODEL_SUBSTITUTE_PATH, 'rb') as f: sub = tomllib.load(f) From e15974345bd41b6f9577afc03cc670280275a0b3 Mon Sep 17 00:00:00 2001 From: DevTekVE Date: Wed, 26 Mar 2025 08:26:21 +0100 Subject: [PATCH 2/2] modeld: Enforce float type for `lag_adjusted_curvature` (#714) Convert safe_desired_curvature to float before returning. This ensures the returned value is explicitly a float, avoiding an issue when serializing it on capnp as it does not recognize numpy.float Co-authored-by: Jason Wen --- sunnypilot/selfdrive/controls/lib/drive_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sunnypilot/selfdrive/controls/lib/drive_helpers.py b/sunnypilot/selfdrive/controls/lib/drive_helpers.py index c6d8d85454..b0fda7bd8c 100644 --- a/sunnypilot/selfdrive/controls/lib/drive_helpers.py +++ b/sunnypilot/selfdrive/controls/lib/drive_helpers.py @@ -24,4 +24,4 @@ def get_lag_adjusted_curvature(steer_delay, v_ego, psis, curvatures): current_curvature_desired - max_curvature_rate * DT_MDL, current_curvature_desired + max_curvature_rate * DT_MDL) - return safe_desired_curvature + return float(safe_desired_curvature)