mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-29 16:23:55 +08:00
Keep Ford PCM cruise buttons separate from SLC confirmation
This commit is contained in:
@@ -177,6 +177,7 @@ 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:
|
||||
@@ -186,6 +187,7 @@ 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):
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
import math
|
||||
|
||||
import pytest
|
||||
from opendbc.car import structs
|
||||
from opendbc.car.dashboard_speed_limit import Observation, Status
|
||||
|
||||
from openpilot.cereal import messaging
|
||||
from openpilot.selfdrive.car.cruise import SlcPendingConfirmation
|
||||
from openpilot.selfdrive.car.cruise import SlcPendingConfirmation, VCruiseHelper
|
||||
from openpilot.starpilot.speed_limits import physical_actions
|
||||
from openpilot.starpilot.speed_limits.selection import Source
|
||||
from openpilot.starpilot.speed_limits.tests.test_runtime_replay import ReplaySM
|
||||
@@ -144,3 +145,44 @@ def test_dashboard_engagement_qualifies_both_samples(sm, state_changes, local_ch
|
||||
'observed_ns': NOW - 5_000_000, 'valid_until_ns': NOW + 145_000_000} | local_changes))
|
||||
|
||||
assert (physical_actions.engagement_state(sm, local, 'card', NOW, after_ns=after_ns) is not None) == matches
|
||||
|
||||
|
||||
@pytest.mark.parametrize('direction', ['accelCruise', 'decelCruise'])
|
||||
@pytest.mark.parametrize('longitudinal', [False, True])
|
||||
def test_ford_pcm_wheel_changes_only_stock_set(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.)]:
|
||||
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
|
||||
assert helper.v_cruise_kph == pytest.approx(speed * 3.6)
|
||||
assert helper.v_cruise_cluster_kph == pytest.approx(speed * 3.6)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('direction', ['accelCruise', 'decelCruise'])
|
||||
def test_ford_software_set_still_consumes_confirmation_without_a_speed_step(direction):
|
||||
cp = structs.CarParams(brand='ford', pcmCruise=False, openpilotLongitudinalControl=True)
|
||||
helper = VCruiseHelper(cp)
|
||||
helper.v_cruise_kph = helper.v_cruise_cluster_kph = 72.
|
||||
cs = structs.CarState(canValid=True)
|
||||
cs.cruiseState.available = cs.cruiseState.enabled = True
|
||||
prompt = SlcPendingConfirmation('planner', 1, 2)
|
||||
cs.buttonEvents = [{'type': direction, 'pressed': True}]
|
||||
helper.update_v_cruise(cs, True, True, prompt, slc_enabled=True)
|
||||
assert helper.slc_consumed_button is not None
|
||||
assert helper.slc_consumed_button.pending == prompt
|
||||
for _ in range(60):
|
||||
cs.buttonEvents = []
|
||||
helper.update_v_cruise(cs, True, True, None, slc_enabled=True)
|
||||
assert helper.v_cruise_kph == 72.
|
||||
cs.buttonEvents = [{'type': direction, 'pressed': False}]
|
||||
helper.update_v_cruise(cs, True, True, None, slc_enabled=True)
|
||||
assert helper.v_cruise_kph == 72.
|
||||
assert not helper.slc_suppressed_buttons
|
||||
|
||||
@@ -681,6 +681,7 @@ 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,13 +1096,14 @@ class TestRuntimeSnapshot(unittest.TestCase):
|
||||
|
||||
@pytest.mark.parametrize('brand,standstill,cruise_standstill,cruise_enabled,expected', [
|
||||
('honda', False, False, True, True),
|
||||
('ford', False, False, True, False),
|
||||
('toyota', False, False, True, True),
|
||||
('toyota', True, False, True, False),
|
||||
('toyota', False, True, True, False),
|
||||
('toyota', False, False, False, False),
|
||||
])
|
||||
def test_wheel_confirmation_hint_preserves_toyota_resume(brand, standstill, cruise_standstill, cruise_enabled, expected, tmp_path):
|
||||
ui = vehicle_ui(tmp_path, carFingerprint='', brand=brand, openpilotLongitudinalControl=True, pcmCruise=brand == 'toyota')
|
||||
ui = vehicle_ui(tmp_path, carFingerprint='', brand=brand, openpilotLongitudinalControl=True, pcmCruise=brand in ('toyota', 'ford'))
|
||||
car = ui.sm['carState']
|
||||
car.canTimeout, car.canValid, car.standstill = False, True, standstill
|
||||
car.cruiseState = NS(available=True, enabled=cruise_enabled, standstill=cruise_standstill)
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "2a935797b3d7b6fa6a6e0563873e4c36e7c6832e7f6ed9b9045caec3de86c908", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "9e5f1f5598ab2d2bd5bafffbec449239f3d5bc18b73e6be0608845e64ed6c1e0", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user