From fbc192941d79f6a3cfc223da16bab4ba3ddf6574 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Fri, 20 Nov 2026 08:40:48 -0600 Subject: [PATCH] Keep stopped Ford leads out of independent light holds --- openpilot/starpilot/conditional_mode/stop.py | 6 +- .../tests/test_stop_commit.py | 65 +++++++++++++++++++ prebuilt.json | 2 +- 3 files changed, 69 insertions(+), 4 deletions(-) diff --git a/openpilot/starpilot/conditional_mode/stop.py b/openpilot/starpilot/conditional_mode/stop.py index 519dc27555..0ecee64b94 100644 --- a/openpilot/starpilot/conditional_mode/stop.py +++ b/openpilot/starpilot/conditional_mode/stop.py @@ -179,11 +179,11 @@ class StopLightDetector: self.commit_clear_since_s = None def _commit_ford_standstill(self, frame: StopFrame, extent: float) -> None: - # Commit only an already established, geometry-qualified stopped hold. - # The model action corroborates that hold; it cannot acquire a light alone. + # A stopped lead owns its own stop; its short forecast cannot identify a light. + # The model action corroborates an established hold, never acquires a light alone. if (frame.car_fingerprint in FORD_STOP_NAMES and frame.standstill is True and frame.pedal_override is False and frame.model_should_stop is True and - frame.longitudinal_stop_active is True and + frame.longitudinal_stop_active is True and frame.lead is not None and frame.lead.present is False and self.standstill_reason == 'light' and self.standstill_model_stopped and extent < FROZEN_RAW_STOP_DISTANCE_M): self._commit(frame, extent, True, True, 0.0) diff --git a/openpilot/starpilot/conditional_mode/tests/test_stop_commit.py b/openpilot/starpilot/conditional_mode/tests/test_stop_commit.py index d72d4ef0c6..2d68223ca9 100644 --- a/openpilot/starpilot/conditional_mode/tests/test_stop_commit.py +++ b/openpilot/starpilot/conditional_mode/tests/test_stop_commit.py @@ -186,3 +186,68 @@ def test_actual_mache_clear_launch_keeps_hold_released(monkeypatch): assert cleared and moving finally: case.doCleanups() + + +def test_ford_stopped_lead_does_not_acquire_an_independent_light_hold(): + from opendbc.car.ford.values import CAR + from openpilot.starpilot.conditional_mode.stop import StopLead + for radar in (True, False): + detector = StopLightDetector() + lead = StopLead(True, 5.5, 0., radar, .999, True) + for tick in range(30): + current = replace(frame(tick, speed=0., standstill=True, horizon=None, model_should_stop=True), + car_fingerprint=str(CAR.FORD_MUSTANG_MACH_E_MK1), standstill_path_extent_m=15., + longitudinal_stop_active=True, lead=lead) + detector.step(current) + assert not detector.committed + for tick in range(30, 50): + detector.step(replace(frame(tick, speed=0., standstill=True, horizon=40., model_should_stop=False), + car_fingerprint=str(CAR.FORD_MUSTANG_MACH_E_MK1), + lead=replace(lead, distance_m=10., speed_mps=1.5))) + assert not detector.committed and not detector.standstill_committed + + +def test_departing_lead_cannot_erase_a_previously_acquired_light(): + from opendbc.car.ford.values import CAR + from openpilot.starpilot.conditional_mode.stop import StopLead + detector = prime() + for tick in range(30, 70): + detector.step(replace(frame(tick, speed=0., standstill=True, horizon=40., model_should_stop=False), + car_fingerprint=str(CAR.FORD_MUSTANG_MACH_E_MK1), + lead=StopLead(True, 10., 1.5, True, .999, True))) + assert detector.committed and detector.standstill_committed + + +def test_mache_following_launch_reaches_native_planner_without_extra_light_hold(monkeypatch): + from opendbc.car.car_helpers import interfaces + from opendbc.car.ford.values import CAR + from openpilot.selfdrive.controls.lib.longitudinal_planner import LongitudinalPlanner + from openpilot.starpilot.longitudinal.tests import test_cem_green_release as green + case = green.CemGreenCallerTests(methodName='runTest') + case.setUp() + case.cp = interfaces[CAR.FORD_MUSTANG_MACH_E_MK1].get_non_essential_params(CAR.FORD_MUSTANG_MACH_E_MK1) + case.cp.openpilotLongitudinalControl = True + case.planner = LongitudinalPlanner(case.cp) + original = green.serialized_scene + departing = False + def following(**kwargs): + kwargs.update(lead_present=True, lead_distance=10. if departing else 5.5, + lead_speed=1.5 if departing else 0., lead_accel=.5 if departing else 0.) + return original(**kwargs) + monkeypatch.setattr(green, 'serialized_scene', following) + xs = [40. * i / 32 for i in range(33)] + xs[1:3] = [.0005, .0002] + try: + for _ in range(30): + _, _, held, _ = case.cycle(stopped=True, position=xs, velocity=[0.] * 33, should_stop=True, desired_accel=0., lead=True) + assert not held + departing = True + moving = False + for _ in range(40): + _, _, held, plan = case.cycle(stopped=True, position=xs, velocity=[float(i) / 4 for i in range(33)], + should_stop=False, desired_accel=.8, lead=True) + assert not held + moving |= not plan.shouldStop and plan.aTarget > .1 + assert moving + finally: + case.doCleanups() diff --git a/prebuilt.json b/prebuilt.json index ea31b4e294..f38626c1db 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "9cfee5dab6e2bd721c9d777910da4629c492130927bb719475f87d03666a91c9", "schema_version": 1} +{"protected_inventory_sha256": "1a322e6bc83d1f6bbc263aa24e6ebfa2e4afdcde287dcaacfe4361d1f1ff127c", "schema_version": 1}