Merge current Dom checks for legacy Prius receiver

This commit is contained in:
firestar5683
2026-10-28 17:51:29 -05:00
3 changed files with 133 additions and 5 deletions
@@ -0,0 +1,125 @@
"""Native stop permission boundaries across HKG policy families."""
import pytest
from opendbc.car.hyundai.canfd_angle_aol import ANGLE_AOL_WORDS
from opendbc.car.hyundai.canfd_stock_aol import STOCK_AOL_WORDS
from opendbc.safety.tests import test_hyundai_classic_long_aol as classiclong
from opendbc.safety.tests import test_hyundai_hda2_long_aol as canfdlong
from opendbc.safety.tests import test_hyundai_shared_canfd_stock_aol as canfdstock
from opendbc.safety.tests import test_hyundai_blended_alpha as blendedlong
from opendbc.safety.tests import test_hyundai_stock_angle_aol as stockangle
@pytest.mark.parametrize('word', [0x404, 0xC04])
def test_classic_long_keeps_native_lateral_through_a_stopped_long_withdrawal(word):
case = classiclong.TestHyundaiClassicLongAol(methodName='runTest')
case.setUp()
try:
case.reset(word)
if case.release:
case.safety.set_controls_allowed(True)
assert case.request(3) == 0
return
for _ in range(6):
case.feed(word)
case.feed(word, button=2)
case.feed(word)
assert not case.safety.get_vehicle_moving()
assert case.request(3) == 3
case.safety.set_controls_allowed(False)
assert case.request(1) == 1
case.safety.set_aol_test_heartbeat(False)
assert case.request(1) == 0
finally:
case.tearDown()
@pytest.mark.parametrize('word', [0x815, 0x895])
def test_canfd_torque_long_keeps_native_lateral_at_a_stop(word):
case = canfdlong.TestHyundaiHda2LongAol(methodName='runTest')
case.setUp()
try:
case.mode(word)
if case.release:
case.safety.set_aol_test_heartbeat(True)
case.safety.set_controls_allowed(True)
case.safety.aol_set_host_request(3)
assert case.safety.aol_get_permission_mask() == 0
return
case.healthy()
case.arm()
assert not case.safety.get_vehicle_moving()
case.safety.set_controls_allowed(True)
case.safety.aol_set_host_request(3)
assert case.safety.aol_get_permission_mask() == 3
case.safety.set_controls_allowed(False)
case.safety.aol_set_host_request(1)
assert case.safety.aol_get_permission_mask() == 1
case.safety.set_aol_test_heartbeat(False)
assert case.safety.aol_get_permission_mask() == 0
finally:
case.tearDown()
def test_every_shared_canfd_stock_word_keeps_stopped_lateral_independent():
case = canfdstock.TestHyundaiSharedCanfdStockAol(methodName='runTest')
case.setUp()
for word in sorted(STOCK_AOL_WORDS):
case.mode(word)
case.healthy(word)
case.gesture(word)
assert not case.safety.get_vehicle_moving()
case.safety.set_controls_allowed(True)
assert case.safety.aol_get_permission_mask() == 1
case.safety.set_controls_allowed(False)
assert case.safety.aol_get_permission_mask() == 1
case.safety.set_aol_test_heartbeat(False)
assert case.safety.aol_get_permission_mask() == 0
@pytest.mark.parametrize('word', [0x2004, 0x2014])
def test_blended_long_keeps_stopped_lateral_without_long_authority(word):
case = blendedlong.TestHyundaiBlendedAlphaAol(methodName='runTest')
case.setUp()
try:
case.reset(word)
if case.release:
case.safety.set_controls_allowed(True)
assert case.request(3) == 0
return
for _ in range(8):
case.feed()
case.feed(lda=True)
case.feed()
assert not case.safety.get_vehicle_moving()
assert case.request(1) == 1
case.safety.set_controls_allowed(True)
assert case.request(3) == 3
case.safety.set_controls_allowed(False)
assert case.request(1) == 1
case.safety.set_aol_test_heartbeat(False)
assert case.request(1) == 0
finally:
case.tearDown()
@pytest.mark.parametrize('word', sorted(ANGLE_AOL_WORDS))
def test_each_stock_angle_word_pauses_native_lateral_at_stop_and_recovers(word):
case = stockangle.TestHyundaiStockAngleAol(methodName='runTest')
case.setUp()
case.mode(word)
case.sources(word)
case.gesture(word)
assert case.safety.get_vehicle_moving()
assert case.safety.aol_get_permission_mask() == 1
case.safety.set_controls_allowed(True)
pt = 1 if word & 16 else 0
speeds = ('WHL_SpdFLVal', 'WHL_SpdFRVal', 'WHL_SpdRLVal', 'WHL_SpdRRVal')
case.rx('WHEEL_SPEEDS', pt, dict(COUNTER=7, **dict.fromkeys(speeds, 0)))
assert not case.safety.get_vehicle_moving()
assert case.safety.aol_get_permission_mask() == 0
case.rx('WHEEL_SPEEDS', pt, dict(COUNTER=8, **dict.fromkeys(speeds, 36)))
assert case.safety.get_vehicle_moving()
assert case.safety.aol_get_permission_mask() == 1
case.safety.set_aol_test_heartbeat(False)
assert case.safety.aol_get_permission_mask() == 0
@@ -11,10 +11,11 @@ from openpilot.starpilot.aol.runtime import current_native
from openpilot.starpilot.aol.tests import test_ioniq_availability as fixture
@pytest.mark.parametrize('engaged', [pytest.param(False, id='aol_only'), pytest.param(True, id='stock_cruise_engaged')])
@pytest.mark.parametrize('identity', sorted(MODELS))
@pytest.mark.parametrize('signal', [False, True])
@pytest.mark.parametrize('brake', [False, True])
def test_native_stop_restriction_withdraws_steering_without_disarming_driver_intent(identity, signal, brake):
def test_native_stop_restriction_withdraws_steering_without_disarming_driver_intent(identity, signal, brake, engaged):
case = fixture.IoniqAvailabilityTests(methodName='runTest')
with ExitStack() as cleanup:
cleanup.callback(case.doCleanups)
@@ -35,7 +36,8 @@ def test_native_stop_restriction_withdraws_steering_without_disarming_driver_int
assert sd.aol_settings.pause_brake_mps == 0.0
rolling = fixture.car_state()
rolling.vEgo = rolling.vEgoRaw = 1.0
axis, _, command = step(2, observed_state=rolling, panda_controls_allowed=False)
rolling.cruiseState.enabled = engaged
axis, _, command = step(2, observed_state=rolling, panda_controls_allowed=engaged)
assert axis.lateralActive and command.latActive
assert receive(10_020_000_000, state=rolling, axis=sd.pm.messages['aolAxisState'],
event=sd.pm.messages['onroadEvents'])
@@ -44,9 +46,10 @@ def test_native_stop_restriction_withdraws_steering_without_disarming_driver_int
stopped.vEgo = stopped.vEgoRaw = 0.0
stopped.standstill = True
stopped.leftBlinker = signal
stopped.cruiseState.enabled = engaged
assert temporary_restriction(card.CP, stopped)
axis, _, command = step(tick, observed_state=stopped, allowed=False, native_request_lat=True,
native_request_long=False, panda_controls_allowed=False)
native_request_long=False, panda_controls_allowed=engaged and not brake)
now = 10_000_000_000 + tick * 10_000_000
native = current_native(sd.sm, sd.CP, now_ns=now, axis_session_id=sd.aol_session_id)
assert native is not None and native.requestedLateral and not native.lateralAllowed
@@ -57,7 +60,7 @@ def test_native_stop_restriction_withdraws_steering_without_disarming_driver_int
event=sd.pm.messages['onroadEvents']), card.aol_card_intent.latch_clear_reason
assert card.aol_card_intent.allowed_latch and not sd.aol_authority_lost
axis, _, command = step(37, observed_state=rolling, allowed=True, native_request_lat=True,
native_request_long=False, panda_controls_allowed=False)
native_request_long=False, panda_controls_allowed=engaged)
assert axis.lateralActive and command.latActive
assert not axis.longitudinalActive and not command.longActive
assert receive(10_370_000_000, state=rolling, axis=sd.pm.messages['aolAxisState'],
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "02ba6e9cfbe0e62152e0978ace0f958926c456fa71eacee61b6beccf7c40a448", "schema_version": 1}
{"protected_inventory_sha256": "f4011f161b5ece5eff29f84d1c4887d94e4b4b42fc80aab10acb56bcb05b9843", "schema_version": 1}