mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 02:23:40 +08:00
Keep stopped Ford leads out of independent light holds
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "9cfee5dab6e2bd721c9d777910da4629c492130927bb719475f87d03666a91c9", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "1a322e6bc83d1f6bbc263aa24e6ebfa2e4afdcde287dcaacfe4361d1f1ff127c", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user