From 139d8cbe03095db69c649e449c2e120441ce70bc Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Wed, 25 Nov 2026 16:42:20 -0600 Subject: [PATCH] Tolerate Model Y launch prediction noise at stops --- .../conditional_mode/stop_release.py | 6 ++++- .../tests/test_stop_release.py | 26 +++++++++++++++++++ prebuilt.json | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/openpilot/starpilot/conditional_mode/stop_release.py b/openpilot/starpilot/conditional_mode/stop_release.py index 6480144815..2c4885e777 100644 --- a/openpilot/starpilot/conditional_mode/stop_release.py +++ b/openpilot/starpilot/conditional_mode/stop_release.py @@ -58,7 +58,11 @@ class StoppedLeadRelease: self.reset() return False velocities, times = tuple(model.velocity.x), tuple(ModelConstants.T_IDXS) - if len(velocities) != 33 or len(times) != 33 or not all(math.isfinite(v) and -.05 <= v <= 100. for v in velocities): + # A stationary Model Y can predict a few centimeters of reverse motion at launch. + prefix_noise = cp.carFingerprint == 'TESLA_MODEL_Y' and min(model.position.x) >= -.03 + if (len(velocities) != 33 or len(times) != 33 or + not all(math.isfinite(v) and (-.08 if prefix_noise and t < .2 else -.05) <= v <= 100. + for v, t in zip(velocities, times, strict=True))): self.reset() return False tail = [v for v, t in zip(velocities, times, strict=True) if t >= 2.] diff --git a/openpilot/starpilot/conditional_mode/tests/test_stop_release.py b/openpilot/starpilot/conditional_mode/tests/test_stop_release.py index 3df141ee73..33fcc54409 100644 --- a/openpilot/starpilot/conditional_mode/tests/test_stop_release.py +++ b/openpilot/starpilot/conditional_mode/tests/test_stop_release.py @@ -165,3 +165,29 @@ def test_niro_actual_cem_hold_releases_only_after_native_go(monkeypatch, vision) assert not case.owner.mode.projector.stop_detector.committed finally: case.doCleanups() + + +@pytest.mark.parametrize(('fingerprint', 'slot', 'velocity', 'prefix_distance', 'clear'), [ + ('TESLA_MODEL_Y', 4, -.075, -.025, True), + ('TESLA_MODEL_Y', 4, -.081, -.025, False), + ('TESLA_MODEL_Y', 6, -.075, -.025, False), + ('TESLA_MODEL_Y', 4, -.075, -.031, False), + ('KIA_NIRO_EV', 4, -.075, -.025, False), +]) +def test_departure_tolerates_only_bounded_model_y_prefix_noise(fingerprint, slot, velocity, prefix_distance, clear): + cp = CarParams(openpilotLongitudinalControl=True, carFingerprint=fingerprint) + owner = StoppedLeadRelease() + detector = SimpleNamespace(committed=True, standstill_committed=True, standstill_reason='light', commit_distance_m=3.) + planner = SimpleNamespace(mpc=SimpleNamespace(solution_status=0), output_should_stop=False, output_a_target=.5, + force_stop_plan=SimpleNamespace(forcing=False, should_stop=False)) + results = [] + for tick in range(13): + now = green.MONO + 1_000_000_000 + tick * 50_000_000 + sm = scene(now, True) + model = sm['modelV2'] + xs, velocities = list(model.position.x), list(model.velocity.x) + xs[4], velocities[slot] = prefix_distance, velocity + model.position.x, model.velocity.x = xs, velocities + results.append(owner.sample(sm, cp, planner, detector, now_ns=now, drive_id=green.MONO-1_000_000_000)) + assert not any(results[:10]) + assert results[10:] == [clear] * 3 diff --git a/prebuilt.json b/prebuilt.json index be18154851..1fd71991dd 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "e84c5192138f8278786fa0d6ba68308a9f7b8c319c4a56a60ee7ced6adc60450", "schema_version": 1} +{"protected_inventory_sha256": "250492ad917d2aeee3e674edf0231149239dc5fb7be574b5139aba85aeecdc28", "schema_version": 1}