mazda: count the dash distance bars the way the cluster does - #11
Open
castawait wants to merge 1 commit into
Open
mazda: count the dash distance bars the way the cluster does#11castawait wants to merge 1 commit into
castawait wants to merge 1 commit into
Conversation
The distance selection went to CRZ_CTRL unmapped, so the cluster showed it reversed. The DBC documents DISTANCE_SETTING as 0 disabled, 1 is 4 bars and 4 is 1 bar, while leadDistanceBars counts up from 1 (closest) to 3. The cluster lights 5 - DISTANCE_SETTING bars, so send 5 - bars. Display only. The following gap the planner keeps comes from T_FOLLOW and is unchanged. The golden tx fixture moves by the CRZ_CTRL gap bit only.
There was a problem hiding this comment.
Thanks for contributing to opendbc! In order for us to review your PR as quickly as possible, check the following:
- Convert your PR to a draft unless it's ready to review
- Read the contributing docs
- Before marking as "ready for review", ensure:
- the goal is clearly stated in the description
- all the tests are passing
- include a route or your device' dongle ID if relevant
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.
Problem
With openpilot longitudinal, the dash shows the following distance reversed: picking the closest setting lights the most bars, and the farthest lights the fewest. The controller passes
leadDistanceBarsto CRZ_CTRLDISTANCE_SETTINGunmapped.leadDistanceBarscounts up from 1 (closest) to 3, while the DBC documentsDISTANCE_SETTINGcounting down: 0 disabled, 1 is 4 bars, 2 is 3 bars, 3 is 2 bars, 4 is 1 bar.Fix
Send
5 - bars, so 1, 2 and 3 bars go out as 4, 3 and 2, and the cluster lights the number of bars selected. Toyota maps its reversed distance field the same way (4 - leadDistanceBars). The default when no setting is present stays 2 bars, now sent as 3.This only changes what the dash shows. The following gap the planner keeps comes from
T_FOLLOWand is unchanged.Validation
test_gap_setting_mirrors_drivernow checks the wire value for each bar count (1 to 4, 2 to 3, 3 to 2). On the unchanged controller all three cases fail.DISTANCE_SETTINGfield. Every other frame is byte identical.ruff checkclean.AI Usage
Disclaimer: Claude Opus 5 by Anthropic was used to help develop, debug, and document this submission. All changes were reviewed and validated by a human.