Skip to content

Subaru: Add 2025 Crosstrek angle steering support#3251

Draft
lukasloetkolben wants to merge 12 commits intocommaai:masterfrom
lukasloetkolben:subaru-crosstrek-2025
Draft

Subaru: Add 2025 Crosstrek angle steering support#3251
lukasloetkolben wants to merge 12 commits intocommaai:masterfrom
lukasloetkolben:subaru-crosstrek-2025

Conversation

@lukasloetkolben
Copy link
Copy Markdown
Contributor

@lukasloetkolben lukasloetkolben commented Mar 28, 2026

Adds lateral control support for the 2025 Subaru Crosstrek, the first angle-based LKAS Subaru to be fully supported. This is a cleanup and rework based on the original work by Jacob Waller in #2864.

  • Dongle ID: 38b065e31c0a9ed7
  • Route: 38b065e31c0a9ed7/0000000b--eab0d07145

Credits

Based on the initial implementation by @jacobwaller (#2864).

@github-actions github-actions bot added car related to opendbc/car/ subaru car safety vehicle-specific safety code labels Mar 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 28, 2026

Car behavior report

Replays driving segments through this PR and compares the behavior to master.
Please review any changes carefully to ensure they are expected.

Testing 79 segments for: SUBARU_ASCENT, SUBARU_OUTBACK, SUBARU_LEGACY, SUBARU_IMPREZA, SUBARU_IMPREZA_2020, SUBARU_FORESTER, SUBARU_OUTBACK_PREGLOBAL, SUBARU_OUTBACK_PREGLOBAL_2018, SUBARU_FORESTER_2022

⚠️ 10 changed, 69 passed, 0 errors

Show changes

SUBARU_FORESTER_2022 - fb44e14ca2557f9b/00000000--dc5c7f659c/9

  carParams.safetyConfigs (1 diffs)
    frame -1: [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 0}] -> [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 8}]

SUBARU_FORESTER_2022 - fb44e14ca2557f9b/0000001c--f00820aa40/19

  carParams.safetyConfigs (1 diffs)
    frame -1: [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 0}] -> [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 8}]

SUBARU_FORESTER_2022 - fb44e14ca2557f9b/0000000d--eca8f1c4eb/5

  carParams.safetyConfigs (1 diffs)
    frame -1: [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 0}] -> [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 8}]

SUBARU_FORESTER_2022 - fb44e14ca2557f9b/0000002d--178c6e6cb6/5

  carParams.safetyConfigs (1 diffs)
    frame -1: [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 0}] -> [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 8}]

SUBARU_FORESTER_2022 - fb44e14ca2557f9b/0000001f--21877cfd0c/10

  carParams.safetyConfigs (1 diffs)
    frame -1: [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 0}] -> [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 8}]

SUBARU_FORESTER_2022 - fb44e14ca2557f9b/0000001f--21877cfd0c/1

  carParams.safetyConfigs (1 diffs)
    frame -1: [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 0}] -> [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 8}]

SUBARU_FORESTER_2022 - fb44e14ca2557f9b/0000000c--59dcc6a17a/8

  carParams.safetyConfigs (1 diffs)
    frame -1: [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 0}] -> [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 8}]

SUBARU_FORESTER_2022 - fb44e14ca2557f9b/00000005--c6fa3c9d05/10

  carParams.safetyConfigs (1 diffs)
    frame -1: [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 0}] -> [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 8}]

SUBARU_FORESTER_2022 - fb44e14ca2557f9b/00000020--1051bd47b4/9

  carParams.safetyConfigs (1 diffs)
    frame -1: [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 0}] -> [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 8}]

SUBARU_FORESTER_2022 - fb44e14ca2557f9b/00000000--dc5c7f659c/3

  carParams.safetyConfigs (1 diffs)
    frame -1: [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 0}] -> [{'safetyModel': 'subaru', 'safetyParamDEPRECATED': 0, 'safetyParam2DEPRECATED': 0, 'safetyParam': 8}]

@lukasloetkolben lukasloetkolben marked this pull request as draft March 28, 2026 23:16
@lukasloetkolben lukasloetkolben force-pushed the subaru-crosstrek-2025 branch 2 times, most recently from 88aae54 to fbd94a4 Compare March 29, 2026 00:23
Co-Authored-By: Jacob Waller <jacobwaller@users.noreply.github.com>
mpurnell1 added a commit to mpurnell1/sunnypilot that referenced this pull request Mar 29, 2026
…ring support

Cherry-picked from commaai/opendbc#3251 onto sunnypilot/opendbc.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment on lines +48 to +52
# heavy steering oscillation at low speeds (up to ~5 mph), still present up to ~22mph
# likely due to poor steering angle sensor resolution or imprecise EPS actuation
if CC.latActive and CS.out.vEgoRaw < 10.0:
deadzone = np.interp(CS.out.vEgoRaw, [2., 10.0], [6.0, 3.0])
apply_angle = self.apply_angle_last + apply_center_deadzone(apply_angle - self.apply_angle_last, deadzone)
Copy link
Copy Markdown
Contributor

@sshane sshane Mar 30, 2026

Choose a reason for hiding this comment

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

likely? do we know why? have a plot of why this is needed showing the car overshooting our request?

afaik current angle is not used to error correct so not sure how that's possible

Comment on lines +86 to +93
if self.CP.flags & SubaruFlags.LKAS_ANGLE:
# ES_Brake->Cruise_Activated stays high on brake at standstill,
# so we use ES_Status->Cruise_Activated which is the correct engaged state.
ret.cruiseState.enabled = cp_es_brake.vl["ES_Status"]['Cruise_Activated'] != 0
ret.cruiseState.available = cp_cam.vl["ES_DashStatus"]['Cruise_On'] != 0
elif self.CP.flags & SubaruFlags.HYBRID:
# ES_Status is missing on hybrid, so we use ES_Brake instead
# TODO: 0x27 and 0x225 on hybrids may work as a replacement
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

removes a todo that I'm not sure is solved yet

Comment on lines +18 to +19
from opendbc.car.subaru.interface import CarInterface
return CarInterface.get_non_essential_params("SUBARU_ASCENT")
Copy link
Copy Markdown
Contributor

@sshane sshane Mar 30, 2026

Choose a reason for hiding this comment

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

need to see the distribution of the angle cars to see if we can set to the minimum one + some tests to check new cars merged.

the Tesla VM safety mode was designed for no override, and two cars that are very similar. now that it's getting used more widely, we need to make it nice to work with and validate safety. that means detecting the car in panda safety if needed

Copy link
Copy Markdown
Contributor

@sshane sshane Mar 30, 2026

Choose a reason for hiding this comment

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

I would like to see data given the Ascent's params on all the new angle Subarus to show the max lateral accel for each (you can just calculate this pretty simply, no driving required)

Comment on lines +22 to +24
MAX_LATERAL_ACCEL=ISO_LATERAL_ACCEL + (ACCELERATION_DUE_TO_GRAVITY * AVERAGE_ROAD_ROLL), # ~3.6 m/s^2
MAX_LATERAL_JERK=3.0 + (ACCELERATION_DUE_TO_GRAVITY * AVERAGE_ROAD_ROLL), # ~3.6 m/s^3
MAX_ANGLE_RATE=5, # deg/frame, comfort rate limit
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

like this can all be common now, we're going to duplicate it in HKG as well

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

Labels

car safety vehicle-specific safety code car related to opendbc/car/ subaru

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants