mazda: add alpha longitudinal support - #460
Draft
yummydirtx wants to merge 2 commits into
Draft
Conversation
There was a problem hiding this comment.
Pull request overview
Adds alpha longitudinal (openpilot-managed ACC) support for Mazda CX-5 2022 by holding the stock radar in a diagnostic session and emulating the key radar-owned cruise frames so MRCC remains usable under openpilot longitudinal control.
Changes:
- Introduce Mazda longitudinal message synthesis (CRZ_INFO/CRZ_CTRL) + radar “tester present”/session management.
- Update Mazda interface/carstate/controller logic to support alpha-long cruise state, buttons, stop/go hold, and resume behavior.
- Extend Panda safety mode + safety tests/DBC to allow and validate new longitudinal-related TX/RX paths.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| opendbc/safety/tests/test_mazda.py | Adds a Mazda longitudinal safety test variant and updates PCM status sourcing for long mode. |
| opendbc/safety/tests/common.py | Adjusts cross-mode TX-hook comparison to account for Mazda long-mode TX superset. |
| opendbc/safety/modes/mazda.h | Adds a Mazda longitudinal safety param, new allowed TX (0x21b/0x21c/0x764), and longitudinal safety checks. |
| opendbc/dbc/mazda_2017.dbc | Refines CRZ_CTRL/CRZ_INFO signal definitions needed for message synthesis/parsing. |
| opendbc/car/mazda/longitudinal.py | New module implementing CRZ_INFO/CRZ_CTRL synthesis and radar UDS session helpers. |
| opendbc/car/mazda/interface.py | Gates openpilot longitudinal to CX-5 2022, sets tuning/params, and enters radar programming session on init. |
| opendbc/car/mazda/carstate.py | Updates cruise availability/enabled logic for radar-suppressed mode; expands button event parsing. |
| opendbc/car/mazda/carcontroller.py | Implements stop/go hold + resume state machine and sends synthetic longitudinal + tester-present frames. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
yummydirtx
marked this pull request as draft
April 23, 2026 19:20
Author
|
Marked this as a draft while I prepare a submission to commaai/opendbc as suggested by sunnyhaibin |
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.
This pull request adds support for full alpha longitudinal on the Mazda CX-5. The method I used to achieve this involved poisoning the stock radar unit by placing it in "programming" session and sending "tester-present" messages to hold it in that state, and then essentially emulating that radar unit enough to prevent a full malfunction that would disable the ability to trigger MRCC. It is important to note that doing this necessarily disables AEB braking, and as of the current state of these changes, triggers a few malfunctions to show on the dash. None of these impair car function, and across many test drives, alpha longitudinal has worked without triggering errors or exhibiting any unusual unsafe behavior.
This is my first contribution to this project, and, clearly, it's a large one in size, so I welcome any and all critiques or suggestions that need to be addressed before merging all this.
The following is Copilot's summary of my changes (reviewed by me):
Longitudinal Control Integration and Logic:
carcontroller.py. This includes new state variables and careful management of transitions between stopping, holding, and starting, as well as handling both physical and virtual resume requests. [1] [2] [3] [4]Cruise State and Button Event Handling:
Car Interface and Parameters:
interface.pyto enable openpilot longitudinal control only for supported models (CX-5 2022), set appropriate car parameters (starting state, accel values, actuator delay, PID tuning), and configure the safety model accordingly. [1] [2] [3]Radar Session Management:
These changes collectively enable a robust openpilot longitudinal control experience on supported Mazda vehicles, with careful handling of state transitions, user inputs, and compatibility with stock systems.
Validation