Hyundai: cover ALT_LIMITS_2 in test_alternate_limits#3523
Hyundai: cover ALT_LIMITS_2 in test_alternate_limits#3523johnnathanwood wants to merge 1 commit into
Conversation
Car behavior reportReplays driving segments through this PR and compares the behavior to master. Testing 260 segments for: HYUNDAI_AZERA_HEV_6TH_GEN, HYUNDAI_ELANTRA_GT_I30, HYUNDAI_ELANTRA_2021, HYUNDAI_ELANTRA_HEV_2021, HYUNDAI_GENESIS, HYUNDAI_IONIQ, HYUNDAI_IONIQ_HEV_2022, HYUNDAI_IONIQ_EV_2020, HYUNDAI_IONIQ_PHEV_2019, HYUNDAI_IONIQ_PHEV, HYUNDAI_KONA_2022, HYUNDAI_KONA_EV, HYUNDAI_KONA_EV_2022, HYUNDAI_KONA_EV_2ND_GEN, HYUNDAI_SANTA_FE, HYUNDAI_SANTA_FE_2022, HYUNDAI_SANTA_FE_HEV_2022, HYUNDAI_SANTA_FE_PHEV_2022, HYUNDAI_SONATA, HYUNDAI_SONATA_LF, HYUNDAI_STARIA_4TH_GEN, HYUNDAI_PALISADE, HYUNDAI_SONATA_HYBRID, HYUNDAI_IONIQ_5, HYUNDAI_IONIQ_6, HYUNDAI_TUCSON_4TH_GEN, HYUNDAI_SANTA_CRUZ_1ST_GEN, HYUNDAI_CUSTIN_1ST_GEN ✅ 0 changed, 256 passed, 4 errors Show errors |
Summary
test_alternate_limitsverifies that the car-sideALT_LIMITS(270 Nm) flag is propagated to thepanda
safetyParam, but the siblingALT_LIMITS_2(170 Nm) tier — added for the Kona 2022 in #2072 —has no equivalent assertion. This adds the missing symmetric check.
Why it matters
The panda steer-torque tier is selected fail-open: with no flag set,
opendbc/safety/modes/hyundai.hfalls back to the 384 Nm default. The car cap (
CarControllerParams.STEER_MAX) and the panda tier arederived independently, and panda cannot re-derive the per-car limit from the bus. So if the
ALT_LIMITS_2flag is set on the car but not propagated intosafetyParam(interface.py), pandasilently enforces 384 for a car that intends 170 — with no RX/TX/
controls_allowedsymptom. That isthe "a simple bug can silently allow more torque than expected" failure mode noted in #1137, and the
dropped-flag regression seen in #2072. The 270 tier is guarded against this today; the 170 tier was not.
Change
Test-only. One added assertion in
test_alternate_limits, mirroring the existingALT_LIMITSline forALT_LIMITS_2.Test plan
pytest opendbc/car/hyundai/tests/test_hyundai.py -k test_alternate_limits— passes on master.ALT_LIMITS_2 → safetyParammapping ininterface.pyis removed: the Konathen reports a
safetyParammissing the bit, so the assertion catches the silent fall-back to 384.Scope / non-goals
car_diffreplay should report 0 changed.safetyParampropagation only. It intentionally does not assert a per-platformexpected cap:
STEER_MAXis also set to non-default values by the CAN-FD and 255 Nm branches ahead ofthe
ALT_LIMITSbranches, so a blanket per-CAR"car cap == panda tier" assertion would false-fail onthose cars.