Skip to content

mazda: LKA button toggles lateral - #14

Open
mzdnick wants to merge 1 commit into
zoompilot:developfrom
mzdnick:mazda-lka-toggle-v2
Open

mzdnick wants to merge 1 commit into
zoompilot:developfrom
mzdnick:mazda-lka-toggle-v2

Conversation

@mzdnick

@mzdnick mzdnick commented Sep 14, 2026

Copy link
Copy Markdown

Depends on #13: it replaces the LANE_LINES == 0 heuristic this PR's button read would otherwise collide with.

Why

  • Non-TJA trims have no wheel button for lateral; the dash LKAS button is the only switch and previously did nothing for openpilot.
  • Toggling it also read as a steering fault under MADS, soft-disabling the whole engagement.

What

  • The dash button's press is read from LANE_LINES (debounced 0 <-> nonzero edge, one lkas ButtonEvent); lkaButtonOff publishes for the parent's lateral-only refusal.
  • One lateral switch per car: a declared TJA button takes priority over the dash button.
  • The delivery watchdog no longer faults on lane-keep-off, and cancel no longer kills a stock ACC run openpilot never joined (stock-long only).

Validation

  • validated on a non-TJA 22 CX-5, TJA not validated.
  • mazda tests: 556 car + 289 safety pass; ruff clean.

AI Usage

Disclaimer: GLM-5.3 by Z.ai was used to help develop, debug, and document this submission. All changes were reviewed and validated by me.

@mzdnick
mzdnick force-pushed the mazda-lka-toggle-v2 branch 4 times, most recently from 08615c3 to 232e947 Compare September 16, 2026 18:38
@mzdnick mzdnick changed the title mazda: dash LKAS button toggles lateral mazda: LKA button toggles lateral Sep 16, 2026
@mzdnick
mzdnick force-pushed the mazda-lka-toggle-v2 branch 2 times, most recently from e1c4cc4 to a61b2a6 Compare September 17, 2026 16:45
@mzdnick
mzdnick marked this pull request as ready for review September 17, 2026 16:48
@mzdnick
mzdnick force-pushed the mazda-lka-toggle-v2 branch 2 times, most recently from d65c14f to 0048775 Compare September 18, 2026 04:29
Issue: non-TJA trims expose no wheel button for lateral; the dash LKAS
button is the only switch, and with MADS on its press read as a steering
fault - the delivery watchdog sees the EPS stop applying torque the
instant the button goes off - instead of the driver choice it is.

Fix: read the button's edge from LANE_LINES, the state the dash button
drives (0 lane keep off, 1-4 lane state): two agreeing frames make a
0 <-> nonzero edge one ButtonType.lkas press, the debounced off state
publishes as lkaButtonOff for a lateral-only refusal, and the panda arms
lateral on the on-press from the same frame, its HUD-frame liveness
check riding the declaration. One lateral switch per car: a declared TJA
button owns the press, the state still publishes. The delivery watchdog
holds through a button-off window and alerts only while a request
stands: the latch can outlive the request that earned it. Stock-long
only: a SET press with LKA off is a stock ACC run openpilot never
joined, so cancel no longer kills it.

The TJA press hands a joined cruise back to the driver: on a
TJA-declared car under stock longitudinal, the press that turns MADS
lateral off leaves the driver's stock MRCC engaged underneath, and
controlsd raises cruiseControl.cancel for exactly that state; the
cancel spam disengaged an MRCC the press never asked about. Clear
cruise_joined every cycle CRZ_BTNS carries the TJA bit, on the press
cycle itself and before the MADS disable lands, so the standing
engagement falls into the never-joined protection; joining the cruise
again re-arms the sync cancel. Alpha-long still cancels, the engagement
there being openpilot's own. Without the declaration carstate publishes
tja_button as zero, so the clause is unreachable on other cars.

The re-enabled button stops overselling control too: the EPS holds
LKAS_BLOCK through standstill, a dash LKA-off, and a fixed ~3 s re-arm
after a re-enable (3.03 to 3.06 s, nine of nine measured dash cycles)
before it takes lateral. carstate publishes the bit debounced (0.2 s) as
latBlocked on carState, so the UI can hold lateral as arming until the
EPS actually grants it.

Validation: mazda suites 562 car + 289 safety passed, 44 skipped, 215
subtests; ruff clean. Route 9ff65375 (2026-09-16): every toggle drove
LANE_LINES to zero and back on marked road, unmarked streets held the
count at one. Stage drive the same evening: boot-off silent arm,
no-entry while off, ON edges engage lateral, and the standing-request
gate silenced the four false warnings seen before it. The re-arm window
was measured on the stage drive's dedicated capture, ten dash cycles.
@mzdnick
mzdnick force-pushed the mazda-lka-toggle-v2 branch from 0048775 to 67fdea7 Compare September 19, 2026 06:59
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