Skip to content

mazda: count the dash distance bars the way the cluster does - #11

Open
castawait wants to merge 1 commit into
zoompilot:developfrom
castawait:mazda-distance-bars
Open

mazda: count the dash distance bars the way the cluster does#11
castawait wants to merge 1 commit into
zoompilot:developfrom
castawait:mazda-distance-bars

Conversation

@castawait

Copy link
Copy Markdown

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 leadDistanceBars to CRZ_CTRL DISTANCE_SETTING unmapped. leadDistanceBars counts up from 1 (closest) to 3, while the DBC documents DISTANCE_SETTING counting 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_FOLLOW and is unchanged.

Validation

  • test_gap_setting_mirrors_driver now 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.
  • The golden tx fixture is regenerated. Against develop's capture, only CRZ_CTRL (0x21C) changes, on buses 0 and 2 (830 frames each), and only in the DISTANCE_SETTING field. Every other frame is byte identical.
  • Mazda car tests: 525 passed. ruff check clean.
  • On-car: the cluster shows the number of bars selected.

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.

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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant