mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-29 16:23:55 +08:00
Show Hyundai lateral activity independently of cruise engagement
This commit is contained in:
@@ -16,4 +16,4 @@ class CanFDDashIcons:
|
||||
self.disengage_frame = frame
|
||||
blinking = self.disengaging and (frame - self.disengage_frame) * DT_CTRL < 1.0
|
||||
self.previous_lateral = lateral_active
|
||||
return 2 if enabled or lateral_active else 3 if blinking else 0
|
||||
return 2 if lateral_active else 3 if blinking else 0
|
||||
|
||||
@@ -75,9 +75,11 @@ def test_qualified_classic_stock_icons_follow_actual_lateral_and_original_blink(
|
||||
|
||||
@pytest.mark.parametrize('marked', [False, True])
|
||||
@pytest.mark.parametrize('enabled,lateral,lkas,lfa', [(False, False, 1, 0), (True, False, 2, 2), (True, True, 2, 2)])
|
||||
def test_existing_ordinary_and_inactive_dash_behavior_is_preserved(marked, enabled, lateral, lkas, lfa):
|
||||
def test_icons_follow_lateral_when_marked_and_keep_unmarked_cruise_display(marked, enabled, lateral, lkas, lfa):
|
||||
ci, parser = controller(marked=marked)
|
||||
step(ci, parser, enabled=enabled, lateral=lateral)
|
||||
if marked and not lateral:
|
||||
lkas, lfa = 1, 0
|
||||
assert parser.vl['LKAS11']['CF_Lkas_FcwOpt_USM'] == lkas
|
||||
assert parser.vl['LFAHDA_MFC']['LFA_Icon_State'] == lfa
|
||||
|
||||
@@ -87,3 +89,20 @@ def test_unmarked_configuration_does_not_gain_lateral_only_icon_override():
|
||||
step(ci, parser, lateral=True)
|
||||
assert parser.vl['LKAS11']['CF_Lkas_FcwOpt_USM'] == 1
|
||||
assert parser.vl['LFAHDA_MFC']['LFA_Icon_State'] == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize('identity', [CAR.HYUNDAI_SONATA_HYBRID, CAR.HYUNDAI_SONATA,
|
||||
CAR.HYUNDAI_ELANTRA_2021, CAR.HYUNDAI_KONA_EV])
|
||||
def test_cruise_stays_engaged_after_lateral_icon_disengages(identity):
|
||||
ci, parser = controller(identity)
|
||||
original = ci.CP.to_dict()
|
||||
for frame in range(135):
|
||||
lateral = frame < 5 or frame >= 125
|
||||
_, packets = step(ci, parser, enabled=True, lateral=lateral)
|
||||
expected = 2 if lateral else 3 if frame < 104 else 0
|
||||
assert parser.vl['LKAS11']['CF_Lkas_FcwOpt_USM'] == (expected or 1)
|
||||
if frame % 5 == 0:
|
||||
assert parser.vl['LFAHDA_MFC']['LFA_Icon_State'] == expected
|
||||
assert parser.vl['LKAS11']['CR_Lkas_StrToqReq'] == 0
|
||||
assert not any(address in (0x420, 0x421) for address, _, _ in packets)
|
||||
assert ci.CP.to_dict() == original
|
||||
|
||||
@@ -13,7 +13,7 @@ class TestCanFDDashIcons(unittest.TestCase):
|
||||
icons = CanFDDashIcons()
|
||||
for frame, enabled, lateral, expected in ((0, False, False, 0), (1, False, True, 2),
|
||||
(2, False, False, 3), (100, False, False, 3),
|
||||
(101, False, False, 0), (102, True, False, 2),
|
||||
(101, False, False, 0), (102, True, False, 0),
|
||||
(103, False, True, 2), (104, False, False, 3)):
|
||||
self.assertEqual(icons.update(frame, enabled, lateral), expected)
|
||||
|
||||
@@ -31,7 +31,7 @@ class TestCanFDDashIcons(unittest.TestCase):
|
||||
if cluster:
|
||||
parser.update([(1_000_000_000 + frame * 10_000_000, cluster)])
|
||||
value = parser.vl['LFAHDA_CLUSTER']
|
||||
expected = 2 if command.enabled or command.latActive else 3 if 10 <= frame < 109 else 0
|
||||
expected = 2 if command.latActive else 3 if 10 <= frame < 109 else 0
|
||||
self.assertEqual(value['LFA_ICON'], expected)
|
||||
self.assertEqual(value['HDA_ICON'], int(command.enabled))
|
||||
|
||||
@@ -66,3 +66,42 @@ class TestCanFDDashIcons(unittest.TestCase):
|
||||
control.latActive = 5 <= tick < 15
|
||||
_, messages = ci.apply(control.as_reader(), stamp)
|
||||
self.assertFalse(any(message[0] == 0x1E0 for message in messages), tick)
|
||||
|
||||
|
||||
def test_longitudinal_engagement_cannot_hold_or_relight_lateral_icon(self):
|
||||
for alternate in (False, True):
|
||||
for aol in (False, True):
|
||||
with self.subTest(alternate=alternate, aol=aol):
|
||||
cp, cs, controller = controller_fixture(alternate, aol=aol)
|
||||
original = cp.to_dict()
|
||||
parser = CANParser(DBC[cp.carFingerprint][Bus.pt], [('LFAHDA_CLUSTER', 0)], controller.CAN.ECAN)
|
||||
command = structs.CarControl(enabled=True, longActive=True)
|
||||
for frame in range(135):
|
||||
command.latActive = frame < 5 or frame >= 125
|
||||
_, messages = controller.update(command.as_reader(), cs, 1_000_000_000 + frame * 10_000_000)
|
||||
cluster = [message for message in messages if message[0] == 0x1E0]
|
||||
self.assertEqual(len(cluster), int(frame % 5 == 0))
|
||||
if cluster:
|
||||
parser.update([(1_000_000_000 + frame * 10_000_000, cluster)])
|
||||
value = parser.vl['LFAHDA_CLUSTER']
|
||||
expected = 2 if command.latActive else 3 if frame < 104 else 0
|
||||
self.assertEqual(value['LFA_ICON'], expected)
|
||||
self.assertEqual(value['HDA_ICON'], 1)
|
||||
self.assertEqual(cp.to_dict(), original)
|
||||
|
||||
|
||||
def test_cruise_transitions_cannot_invert_lateral_icon_at_standstill(self):
|
||||
for alternate in (False, True):
|
||||
cp, cs, controller = controller_fixture(alternate, aol=True)
|
||||
self.assertEqual(cs.out.vEgo, 0.0)
|
||||
parser = CANParser(DBC[cp.carFingerprint][Bus.pt], [('LFAHDA_CLUSTER', 0)], controller.CAN.ECAN)
|
||||
command = structs.CarControl(latActive=True)
|
||||
for frame in range(40):
|
||||
command.enabled = 10 <= frame < 30
|
||||
command.longActive = command.enabled
|
||||
_, messages = controller.update(command.as_reader(), cs, 1_000_000_000 + frame * 10_000_000)
|
||||
cluster = [message for message in messages if message[0] == 0x1E0]
|
||||
if cluster:
|
||||
parser.update([(1_000_000_000 + frame * 10_000_000, cluster)])
|
||||
self.assertEqual(parser.vl['LFAHDA_CLUSTER']['LFA_ICON'], 2)
|
||||
self.assertEqual(parser.vl['LFAHDA_CLUSTER']['HDA_ICON'], int(command.enabled))
|
||||
|
||||
@@ -138,7 +138,7 @@ def test_actual_controller_cluster_lifecycle(cp):
|
||||
if cluster:
|
||||
parser.update([((frame + 1) * 10_000_000, cluster)])
|
||||
values = parser.vl["LFAHDA_CLUSTER"]
|
||||
expected = 2 if command.enabled or command.latActive else 3 if 10 <= frame < 109 else 0
|
||||
expected = 2 if command.latActive else 3 if 10 <= frame < 109 else 0
|
||||
assert values["LFA_ICON"] == expected
|
||||
assert values["HDA_ICON"] == int(command.enabled)
|
||||
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "d38c1c1123286de21b2454f96eac8495a50569f924f19b98b2a4bd71c3b827fe", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "0211afd188b3c8a41965352bd7817c834d718c71aa4daf20581ab71d0ad74cc3", "schema_version": 1}
|
||||
|
||||
@@ -441,6 +441,8 @@ RELEASE_TARGETS = (
|
||||
"opendbc_repo/opendbc/car/hyundai/tests/test_dom_radar_complete_paths.py",
|
||||
"opendbc_repo/opendbc/car/hyundai/tests/test_dom_firmware_catalog.py",
|
||||
"opendbc_repo/opendbc/car/hyundai/tests/test_canfd_lfa_status.py",
|
||||
"opendbc_repo/opendbc/car/hyundai/tests/test_ioniq6_dash_icons.py",
|
||||
"opendbc_repo/opendbc/car/hyundai/tests/test_torque_ev_scc.py",
|
||||
"opendbc_repo/opendbc/safety/tests/test_hyundai_classic_long_aol.py",
|
||||
"openpilot/starpilot/aol/tests/test_classic_long_profiles.py",
|
||||
"opendbc_repo/opendbc/safety/tests/test_hyundai_shared_canfd_stock_aol.py",
|
||||
|
||||
Reference in New Issue
Block a user