Restore Ford steering-wheel speed-limit confirmation

This commit is contained in:
firestar5683
2026-11-20 07:55:17 -06:00
parent cb3bfc720b
commit 555dac7d12
5 changed files with 27 additions and 9 deletions
-2
View File
@@ -177,7 +177,6 @@ class VCruiseHelper:
self.pcm_slc_sample = (float(self.v_cruise_kph), now_ns)
def _update_slc_button_latches(self, CS, enabled, slc_pending: SlcPendingConfirmation | None) -> None:
# Ford PCM buttons reach OEM cruise even when a host-side press is consumed.
for b in CS.buttonEvents:
button = b.type.raw
if button not in self.button_timers:
@@ -187,7 +186,6 @@ class VCruiseHelper:
self.slc_released_suppressed = True
self.button_timers[button] = 0
elif (b.pressed and enabled and CS.cruiseState.available and slc_pending is not None and
not (self.CP.brand == 'ford' and self.CP.pcmCruise) and
not (self.CP.pcmCruise and button == ButtonType.accelCruise and
(CS.standstill or CS.cruiseState.standstill or not CS.cruiseState.enabled)) and
button not in self.slc_suppressed_buttons):
@@ -149,19 +149,25 @@ def test_dashboard_engagement_qualifies_both_samples(sm, state_changes, local_ch
@pytest.mark.parametrize('direction', ['accelCruise', 'decelCruise'])
@pytest.mark.parametrize('longitudinal', [False, True])
def test_ford_pcm_wheel_changes_only_stock_set(direction, longitudinal):
def test_ford_pcm_confirmation_keeps_oem_set_speed_feedback(direction, longitudinal):
cp = structs.CarParams(brand='ford', pcmCruise=True, openpilotLongitudinalControl=longitudinal)
helper = VCruiseHelper(cp)
cs = structs.CarState(canValid=True)
cs.cruiseState.available = cs.cruiseState.enabled = True
cs.cruiseState.speed = cs.cruiseState.speedCluster = 20.
prompt = SlcPendingConfirmation('planner', 1, 2)
for pressed, speed in [(True, 20.), (True, 21. if direction == 'accelCruise' else 19.), (False, 21. if direction == 'accelCruise' else 19.)]:
for index, (pressed, speed) in enumerate([
(True, 20.), (True, 21. if direction == 'accelCruise' else 19.), (False, 21. if direction == 'accelCruise' else 19.)]):
cs.cruiseState.speed = cs.cruiseState.speedCluster = speed
cs.buttonEvents = [{'type': direction, 'pressed': pressed}]
helper.update_v_cruise(cs, True, True, prompt, slc_enabled=True)
assert helper.slc_consumed_button is None
assert not helper.slc_suppressed_buttons
if longitudinal and index == 0:
assert helper.slc_consumed_button is not None
assert helper.slc_consumed_button.pending == prompt
assert helper.slc_consumed_button.button == ('accel' if direction == 'accelCruise' else 'decel')
else:
assert helper.slc_consumed_button is None
assert bool(helper.slc_suppressed_buttons) == (longitudinal and pressed)
assert helper.v_cruise_kph == pytest.approx(speed * 3.6)
assert helper.v_cruise_cluster_kph == pytest.approx(speed * 3.6)
@@ -186,3 +192,18 @@ def test_ford_software_set_still_consumes_confirmation_without_a_speed_step(dire
helper.update_v_cruise(cs, True, True, None, slc_enabled=True)
assert helper.v_cruise_kph == 72.
assert not helper.slc_suppressed_buttons
@pytest.mark.parametrize('standstill,cruise_standstill,cruise_enabled', [
(True, False, True), (False, True, True), (False, False, False),
])
def test_ford_pcm_resume_is_not_consumed_by_pending_slc(standstill, cruise_standstill, cruise_enabled):
cp = structs.CarParams(brand='ford', pcmCruise=True, openpilotLongitudinalControl=True)
helper = VCruiseHelper(cp)
cs = structs.CarState(canValid=True, standstill=standstill)
cs.cruiseState.available = True
cs.cruiseState.enabled, cs.cruiseState.standstill = cruise_enabled, cruise_standstill
cs.buttonEvents = [{'type': 'accelCruise', 'pressed': True}]
helper.update_v_cruise(cs, True, True, SlcPendingConfirmation('planner', 1, 2), slc_enabled=True)
assert helper.slc_consumed_button is None
assert not helper.slc_suppressed_buttons
@@ -681,7 +681,6 @@ class RuntimeSnapshotAdapter:
cruise_state = getattr(car, 'cruiseState', None)
wheel_confirmation = bool(
system_long and control is not None and getattr(control, 'enabled', False) and
not (cp is not None and cp.brand == 'ford' and cp.pcmCruise) and
cruise_state is not None and getattr(cruise_state, 'available', False) and
not (cp is not None and getattr(cp, 'brand', '') == 'toyota' and
(car.standstill or cruise_state.standstill or not cruise_state.enabled)))
@@ -1096,7 +1096,7 @@ class TestRuntimeSnapshot(unittest.TestCase):
@pytest.mark.parametrize('brand,standstill,cruise_standstill,cruise_enabled,expected', [
('honda', False, False, True, True),
('ford', False, False, True, False),
('ford', False, False, True, True),
('toyota', False, False, True, True),
('toyota', True, False, True, False),
('toyota', False, True, True, False),
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "2d7c1fdad31a4a13ccceac06a49a027af628f97d656b059b4e734556e8f70104", "schema_version": 1}
{"protected_inventory_sha256": "2898cc4df08494c5b6c9bcbd4bdcaecf6245c07bdd8e32b4b4c493d1d8e19b65", "schema_version": 1}