Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Subaru Forester 2022 #26700

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
11b9e05
Add support for Subaru Forester 2022
martinl Dec 4, 2022
7923ce9
Use ES_Status Cruise_Activated
martinl Dec 11, 2022
c742ed5
bump panda
martinl Dec 11, 2022
9b370ee
Merge remote-tracking branch 'upstream/master' into forester-2022-PR
martinl Jul 5, 2023
ca826ea
Update subaru_c harness syntax
martinl Jul 5, 2023
e126d4c
bump panda
martinl Jul 5, 2023
1233ea5
bump submodules + add test route
jnewb1 Jul 11, 2023
b1a4ab8
add to releases
jnewb1 Jul 11, 2023
9330a9e
wip
jnewb1 Jul 13, 2023
b8876bf
merge
jnewb1 Jul 13, 2023
a0f76a3
bump refs
jnewb1 Jul 13, 2023
579dd3d
bump submodules
jnewb1 Jul 13, 2023
555aa6e
fix unittest
jnewb1 Jul 13, 2023
8b4ac8b
bump submodules and group forester into global_gen3
jnewb1 Jul 14, 2023
b66c773
more cleanup
jnewb1 Jul 14, 2023
fa8f42b
Merge branch 'master' into forester-2022-PR
jnewb1 Jul 16, 2023
1270e75
bump panda
jnewb1 Jul 16, 2023
e744f45
Merge branch 'master'
jnewb1 Jul 17, 2023
a2f3762
bump submodules
jnewb1 Jul 17, 2023
82a10f6
forester fingerprints
jnewb1 Jul 17, 2023
4e9cac8
bump panda
jnewb1 Jul 17, 2023
766a116
update docs
jnewb1 Jul 17, 2023
5a41c81
bump panda
jnewb1 Jul 18, 2023
4d89708
bump submodules
jnewb1 Jul 18, 2023
ac0211e
bump submodules
jnewb1 Jul 18, 2023
d0b5081
bump dbc
jnewb1 Jul 18, 2023
5923c2d
split gen3
jnewb1 Jul 18, 2023
89f1df8
bump submodules
jnewb1 Jul 18, 2023
40b5791
Merge branch 'forester-2022-PR' of https://github.com/martinl/openpil…
jnewb1 Jul 18, 2023
c82ee9a
missing comma
jnewb1 Jul 18, 2023
ccdb8b5
fix safety parameters
jnewb1 Jul 18, 2023
5505708
bump panda
jnewb1 Jul 18, 2023
98053a1
use old lkas message
jnewb1 Jul 20, 2023
eb5f400
fix linter
jnewb1 Jul 20, 2023
ee812c1
allow alt lkas
jnewb1 Jul 20, 2023
12d74b6
fix misra
jnewb1 Jul 20, 2023
ad8460c
steering angle based controller
jnewb1 Jul 20, 2023
b0cd706
steering angle based controller
jnewb1 Jul 20, 2023
e54d35b
bump panda
jnewb1 Jul 20, 2023
9e1bf32
cleanup
jnewb1 Jul 20, 2023
2fa2483
merge
jnewb1 Jul 20, 2023
05c7386
bump submodules
jnewb1 Jul 21, 2023
8ed111f
Merge branch 'master' into forester-2022-PR
jnewb1 Jul 21, 2023
7fff11d
Merge remote-tracking branch 'origin/master' into forester-2022-PR
jnewb1 Jul 21, 2023
d891f91
bump
jnewb1 Jul 21, 2023
9462f14
bump panda
jnewb1 Jul 21, 2023
cc30750
bump
jnewb1 Jul 21, 2023
27eda9f
bump cereal
jnewb1 Jul 21, 2023
a72e651
comments
jnewb1 Jul 21, 2023
b662fbb
fix apply steer
jnewb1 Jul 21, 2023
02558eb
fix replay
jnewb1 Jul 21, 2023
e4634c4
minimize diff
jnewb1 Jul 21, 2023
49fa305
hotfix
jnewb1 Jul 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[submodule "panda"]
path = panda
url = ../../commaai/panda.git
url = ../../martinl/panda.git
branch = forester-2022-PR
[submodule "opendbc"]
path = opendbc
url = ../../commaai/opendbc.git
Expand Down
3 changes: 2 additions & 1 deletion docs/CARS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

A supported vehicle is one that just works when you install a comma three. All supported cars provide a better experience than any stock system.

# 217 Supported Cars
# 218 Supported Cars

|Make|Model|Supported Package|ACC|No ACC accel below|No ALC below|Steering Torque|Resume from stop|Harness|
|---|---|---|:---:|:---:|:---:|:---:|:---:|:---:|
Expand Down Expand Up @@ -141,6 +141,7 @@ A supported vehicle is one that just works when you install a comma three. All s
|Subaru|Crosstrek 2018-19|EyeSight Driver Assistance|Stock|0 mph|0 mph|[![star](assets/icon-star-empty.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|Subaru A|
|Subaru|Crosstrek 2020-23|EyeSight Driver Assistance|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|Subaru A|
|Subaru|Forester 2019-21|All|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|Subaru A|
|Subaru|Forester 2022|EyeSight Driver Assistance|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|Subaru C|
|Subaru|Impreza 2017-19|EyeSight Driver Assistance|Stock|0 mph|0 mph|[![star](assets/icon-star-empty.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|Subaru A|
|Subaru|Impreza 2020-22|EyeSight Driver Assistance|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|Subaru A|
|Subaru|Legacy 2020-22|All|Stock|0 mph|0 mph|[![star](assets/icon-star-full.svg)](##)|[![star](assets/icon-star-empty.svg)](##)|Subaru B|
Expand Down
2 changes: 1 addition & 1 deletion panda
1 change: 1 addition & 0 deletions release/files_common
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ opendbc/nissan_x_trail_2017.dbc
opendbc/nissan_leaf_2018.dbc

opendbc/subaru_global_2017_generated.dbc
opendbc/subaru_global_2022_generated.dbc
opendbc/subaru_outback_2015_generated.dbc
opendbc/subaru_outback_2019_generated.dbc
opendbc/subaru_forester_2017_generated.dbc
Expand Down
1 change: 1 addition & 0 deletions selfdrive/car/docs_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Harness(Enum):
toyota = "Toyota"
subaru_a = "Subaru A"
subaru_b = "Subaru B"
subaru_c = "Subaru C"
fca = "FCA"
ram = "Ram"
vw = "VW"
Expand Down
4 changes: 3 additions & 1 deletion selfdrive/car/subaru/carcontroller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from opendbc.can.packer import CANPacker
from selfdrive.car import apply_std_steer_torque_limits
from selfdrive.car.subaru import subarucan
from selfdrive.car.subaru.values import DBC, GLOBAL_GEN2, PREGLOBAL_CARS, CarControllerParams
from selfdrive.car.subaru.values import DBC, CAR, GLOBAL_GEN2, PREGLOBAL_CARS, CarControllerParams


class CarController:
Expand Down Expand Up @@ -41,6 +41,8 @@ def update(self, CC, CS):

if self.CP.carFingerprint in PREGLOBAL_CARS:
can_sends.append(subarucan.create_preglobal_steering_control(self.packer, apply_steer))
elif self.CP.carFingerprint == CAR.FORESTER_2022:
can_sends.append(subarucan.create_steering_control_2(self.packer, apply_steer))
else:
can_sends.append(subarucan.create_steering_control(self.packer, apply_steer))

Expand Down
10 changes: 7 additions & 3 deletions selfdrive/car/subaru/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ def update(self, cp, cp_cam, cp_body):
steer_threshold = 75 if self.CP.carFingerprint in PREGLOBAL_CARS else 80
ret.steeringPressed = abs(ret.steeringTorque) > steer_threshold

cp_cruise = cp_body if self.car_fingerprint in GLOBAL_GEN2 else cp
ret.cruiseState.enabled = cp_cruise.vl["CruiseControl"]["Cruise_Activated"] != 0
ret.cruiseState.available = cp_cruise.vl["CruiseControl"]["Cruise_On"] != 0
if self.car_fingerprint == CAR.FORESTER_2022:
ret.cruiseState.enabled = cp_cam.vl["ES_DashStatus"]['Cruise_Activated'] != 0
ret.cruiseState.available = cp_cam.vl["ES_DashStatus"]['Cruise_On'] != 0
martinl marked this conversation as resolved.
Show resolved Hide resolved
else:
cp_cruise = cp_body if self.car_fingerprint in GLOBAL_GEN2 else cp
ret.cruiseState.enabled = cp_cruise.vl["CruiseControl"]["Cruise_Activated"] != 0
ret.cruiseState.available = cp_cruise.vl["CruiseControl"]["Cruise_On"] != 0
ret.cruiseState.speed = cp_cam.vl["ES_DashStatus"]["Cruise_Set_Speed"] * CV.KPH_TO_MS

if (self.car_fingerprint in PREGLOBAL_CARS and cp.vl["Dash_State2"]["UNITS"] == 1) or \
Expand Down
4 changes: 3 additions & 1 deletion selfdrive/car/subaru/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long):
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.subaru)]
if candidate in GLOBAL_GEN2:
ret.safetyConfigs[0].safetyParam |= Panda.FLAG_SUBARU_GEN2
elif candidate == CAR.FORESTER_2022:
ret.safetyConfigs[0].safetyParam |= Panda.FLAG_SUBARU_FORESTER_2022

ret.steerLimitTimer = 0.4
ret.steerActuatorDelay = 0.1
Expand Down Expand Up @@ -60,7 +62,7 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long):
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0., 14., 23.], [0., 14., 23.]]
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.045, 0.042, 0.20], [0.04, 0.035, 0.045]]

elif candidate == CAR.FORESTER:
elif candidate in (CAR.FORESTER, CAR.FORESTER_2022):
ret.mass = 1568. + STD_CARGO_KG
ret.wheelbase = 2.67
ret.centerToFront = ret.wheelbase * 0.5
Expand Down
8 changes: 8 additions & 0 deletions selfdrive/car/subaru/subarucan.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ def create_steering_control(packer, apply_steer):
}
return packer.make_can_msg("ES_LKAS", 0, values)

def create_steering_control_2(packer, apply_steer):
values = {
"LKAS_Output": apply_steer,
"LKAS_Request": 1 if apply_steer != 0 else 0,
"SET_3": 3
}
return packer.make_can_msg("ES_LKAS_2", 0, values)

def create_steering_status(packer):
return packer.make_can_msg("ES_LKAS_State", 0, {})

Expand Down
24 changes: 24 additions & 0 deletions selfdrive/car/subaru/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class CAR:
IMPREZA = "SUBARU IMPREZA LIMITED 2019"
IMPREZA_2020 = "SUBARU IMPREZA SPORT 2020"
FORESTER = "SUBARU FORESTER 2019"
FORESTER_2022 = "SUBARU FORESTER 2022"
OUTBACK = "SUBARU OUTBACK 6TH GEN"
LEGACY = "SUBARU LEGACY 7TH GEN"

Expand Down Expand Up @@ -67,6 +68,7 @@ class SubaruCarInfo(CarInfo):
SubaruCarInfo("Subaru XV 2020-21"),
],
CAR.FORESTER: SubaruCarInfo("Subaru Forester 2019-21", "All"),
CAR.FORESTER_2022: SubaruCarInfo("Subaru Forester 2022", harness=Harness.subaru_c),
CAR.FORESTER_PREGLOBAL: SubaruCarInfo("Subaru Forester 2017-18"),
CAR.LEGACY_PREGLOBAL: SubaruCarInfo("Subaru Legacy 2015-18"),
CAR.OUTBACK_PREGLOBAL: SubaruCarInfo("Subaru Outback 2015-17"),
Expand Down Expand Up @@ -299,6 +301,27 @@ class SubaruCarInfo(CarInfo):
b'\x1a\xf6b0\x00',
],
},
CAR.FORESTER_2022: {
(Ecu.abs, 0x7b0, None): [
b'\xa3 !x\x00',
b'\xa3 !v\x00',
],
(Ecu.eps, 0x746, None): [
b'-\xc0%0',
b'-\xc0\x040',
],
(Ecu.fwdCamera, 0x787, None): [
b'\x04!\x01\x1eD\x07!\x00\x04,'
],
(Ecu.engine, 0x7e0, None): [
b'\xd5"a0\x07',
b'\xd5"`0\x07',
],
(Ecu.transmission, 0x7e1, None): [
b'\x1d\x86B0\x00',
b'\x1d\xf6B0\x00',
],
},
CAR.FORESTER_PREGLOBAL: {
(Ecu.abs, 0x7b0, None): [
b'\x7d\x97\x14\x40',
Expand Down Expand Up @@ -505,6 +528,7 @@ class SubaruCarInfo(CarInfo):
CAR.IMPREZA: dbc_dict('subaru_global_2017_generated', None),
CAR.IMPREZA_2020: dbc_dict('subaru_global_2017_generated', None),
CAR.FORESTER: dbc_dict('subaru_global_2017_generated', None),
CAR.FORESTER_2022: dbc_dict('subaru_global_2022_generated', None),
CAR.OUTBACK: dbc_dict('subaru_global_2017_generated', None),
CAR.LEGACY: dbc_dict('subaru_global_2017_generated', None),
CAR.FORESTER_PREGLOBAL: dbc_dict('subaru_forester_2017_generated', None),
Expand Down
1 change: 1 addition & 0 deletions selfdrive/car/torque_data/substitute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ SEAT LEON 3RD GEN: VOLKSWAGEN GOLF 7TH GEN
SEAT ATECA 1ST GEN: VOLKSWAGEN GOLF 7TH GEN

SUBARU LEGACY 7TH GEN: SUBARU OUTBACK 6TH GEN
SUBARU FORESTER 2022: SUBARU FORESTER 2019

# Old subarus don't have much data guessing it's like low torque impreza
SUBARU OUTBACK 2018 - 2019: SUBARU IMPREZA LIMITED 2019
Expand Down