From cc734c4c163da5fc9430be478a9dde18ca11d4f7 Mon Sep 17 00:00:00 2001 From: Martin Lillepuu Date: Thu, 9 May 2019 11:26:55 +0300 Subject: [PATCH] adding Subaru XV 2018 support --- selfdrive/car/subaru/carcontroller.py | 2 +- selfdrive/car/subaru/interface.py | 2 +- selfdrive/car/subaru/subarucan.py | 6 +++--- selfdrive/car/subaru/values.py | 6 ++++++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/selfdrive/car/subaru/carcontroller.py b/selfdrive/car/subaru/carcontroller.py index 33a0fde868aed9..bd016904c88bd5 100644 --- a/selfdrive/car/subaru/carcontroller.py +++ b/selfdrive/car/subaru/carcontroller.py @@ -13,7 +13,7 @@ def __init__(self, car_fingerprint): self.STEER_STEP = 2 # how often we update the steer cmd self.STEER_DELTA_UP = 50 # torque increase per refresh, 0.8s to max self.STEER_DELTA_DOWN = 70 # torque decrease per refresh - if car_fingerprint == CAR.IMPREZA: + if car_fingerprint in [CAR.IMPREZA, CAR.XV]: self.STEER_DRIVER_ALLOWANCE = 60 # allowed driver torque before start limiting self.STEER_DRIVER_MULTIPLIER = 10 # weight driver torque heavily self.STEER_DRIVER_FACTOR = 1 # from dbc diff --git a/selfdrive/car/subaru/interface.py b/selfdrive/car/subaru/interface.py index ef3da2f3983340..9d335c4cbe632a 100644 --- a/selfdrive/car/subaru/interface.py +++ b/selfdrive/car/subaru/interface.py @@ -59,7 +59,7 @@ def get_params(candidate, fingerprint): std_cargo = 136 ret.steerRateCost = 0.7 - if candidate in [CAR.IMPREZA]: + if candidate in [CAR.IMPREZA, CAR.XV]: ret.mass = 1568 + std_cargo ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.5 diff --git a/selfdrive/car/subaru/subarucan.py b/selfdrive/car/subaru/subarucan.py index 5e17cd72c70724..1b78b9ff313b72 100644 --- a/selfdrive/car/subaru/subarucan.py +++ b/selfdrive/car/subaru/subarucan.py @@ -11,9 +11,9 @@ def subaru_checksum(packer, values, addr): def create_steering_control(packer, car_fingerprint, apply_steer, frame, steer_step): - if car_fingerprint == CAR.IMPREZA: + if car_fingerprint in [CAR.IMPREZA, CAR.XV]: #counts from 0 to 15 then back to 0 + 16 for enable bit - idx = ((frame // steer_step) % 16) + idx = ((frame / steer_step) % 16) values = { "Counter": idx, @@ -27,7 +27,7 @@ def create_steering_control(packer, car_fingerprint, apply_steer, frame, steer_s def create_steering_status(packer, car_fingerprint, apply_steer, frame, steer_step): - if car_fingerprint == CAR.IMPREZA: + if car_fingerprint in [CAR.IMPREZA, CAR.XV]: values = {} values["Checksum"] = subaru_checksum(packer, {}, 0x322) diff --git a/selfdrive/car/subaru/values.py b/selfdrive/car/subaru/values.py index 18b89295648731..e21188987ea970 100644 --- a/selfdrive/car/subaru/values.py +++ b/selfdrive/car/subaru/values.py @@ -2,17 +2,23 @@ class CAR: IMPREZA = "SUBARU IMPREZA LIMITED 2019" + XV = "SUBARU XV ACTIVE 2018" FINGERPRINTS = { CAR.IMPREZA: [{ 2: 8, 64: 8, 65: 8, 72: 8, 73: 8, 280: 8, 281: 8, 290: 8, 312: 8, 313: 8, 314: 8, 315: 8, 316: 8, 326: 8, 544: 8, 545: 8, 546: 8, 552: 8, 554: 8, 557: 8, 576: 8, 577: 8, 722: 8, 801: 8, 802: 8, 805: 8, 808: 8, 816: 8, 826: 8, 837: 8, 838: 8, 839: 8, 842: 8, 912: 8, 915: 8, 940: 8, 1614: 8, 1617: 8, 1632: 8, 1650: 8, 1657: 8, 1658: 8, 1677: 8, 1697: 8, 1722: 8, 1743: 8, 1759: 8, 1786: 5, 1787: 5, 1788: 8, 1809: 8, 1813: 8, 1817: 8, 1821: 8, 1840: 8, 1848: 8, 1924: 8, 1932: 8, 1952: 8, 1960: 8 }], + CAR.XV: [{ + 2: 8, 64: 8, 65: 8, 72: 8, 73: 8, 280: 8, 281: 8, 290: 8, 312: 8, 313: 8, 314: 8, 315: 8, 316: 8, 326: 8, 372: 8, 544: 8, 545: 8, 546: 8, 554: 8, 557: 8, 576: 8, 577: 8, 722: 8, 801: 8, 802: 8, 805: 8, 808: 8, 811: 8, 826: 8, 837: 8, 838: 8, 839: 8, 842: 8, 912: 8, 915: 8, 940: 8, 1614: 8, 1617: 8, 1632: 8, 1650: 8, 1657: 8, 1658: 8, 1677: 8, 1697: 8, 1759: 8, 1786: 5, 1787: 5, 1788: 8 + }], } STEER_THRESHOLD = { CAR.IMPREZA: 80, + CAR.XV: 80, } DBC = { CAR.IMPREZA: dbc_dict('subaru_global_2017', None), + CAR.XV: dbc_dict('subaru_global_2017', None), }