safety: recover Toyota LTA after torque oscillation - #3686
Open
danielpolimac wants to merge 1 commit into
Open
Conversation
Contributor
Car behavior reportReplays driving segments through this PR and compares the behavior to master. Testing 190 segments for: TOYOTA_ALPHARD_TSS2, TOYOTA_AVALON, TOYOTA_AVALON_2019, TOYOTA_AVALON_TSS2, TOYOTA_CAMRY, TOYOTA_CAMRY_TSS2, TOYOTA_CHR, TOYOTA_CHR_TSS2, TOYOTA_COROLLA, TOYOTA_COROLLA_TSS2, TOYOTA_HIGHLANDER, TOYOTA_HIGHLANDER_TSS2, TOYOTA_PRIUS, TOYOTA_PRIUS_V, TOYOTA_PRIUS_TSS2, TOYOTA_RAV4, TOYOTA_RAV4H, TOYOTA_RAV4_TSS2, TOYOTA_RAV4_TSS2_2022, TOYOTA_RAV4_TSS2_2023, TOYOTA_RAV4_PRIME, TOYOTA_YARIS, TOYOTA_MIRAI, TOYOTA_SIENNA, TOYOTA_SIENNA_4TH_GEN Show changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes Toyota LTA safety incorrectly blocking valid torque re-enable after an oscillating EPS torque signal settles to zero.
Related to commaai/openpilot#32425 and the regression described in commaai/panda#1948.
Root cause
The LTA torque wind-down check used the minimum and maximum over the full six-sample measurement window. After an alternating high positive/negative torque sequence, those stale extrema remained above the threshold even after the newest EPS torque measurement was zero.
Use the newest sample and the sample three messages ago (60 ms) instead. This preserves a short measurement tolerance while allowing a settled torque value to recover promptly.
Regression test
The new test first reproduces the failure:
The test fails on upstream
masterbefore this fix and passes with it.Validation
python -m unittest opendbc.safety.tests.test_toyota.TestToyotaSafetyAngle -vgit diff --check