From 9fc826cb5c6fc46ebd0fe5c1ecd322a472da44ef Mon Sep 17 00:00:00 2001 From: Andre Volmensky Date: Sun, 31 May 2020 12:25:32 +0900 Subject: [PATCH] Added Rogue 2019/Leaf 2019 fingerprints (#1605) * Added Rogue 2019/Leaf 2019 fingerprints * Added Rogue as new car. Updated readme * Added route to test_car_models.py. Fixed if statements to check against rogue/x-trail * Fixed paste error * Merged Leaf fingerprints * Assume Rogue is MPH until we work out the mph/kph bit --- README.md | 3 ++- selfdrive/car/nissan/carcontroller.py | 2 +- selfdrive/car/nissan/carstate.py | 14 ++++++++------ selfdrive/car/nissan/interface.py | 2 +- selfdrive/car/nissan/values.py | 9 ++++++++- selfdrive/test/test_car_models.py | 4 ++++ 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b1bd090e9..80c48babe 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,8 @@ Community Maintained Cars and Features | Kia | Optima 20192 | SCC + LKAS | Stock | 0mph | 0mph | | Kia | Sorento 20182 | SCC + LKAS | Stock | 0mph | 0mph | | Kia | Stinger 20182 | SCC + LKAS | Stock | 0mph | 0mph | -| Nissan | Leaf 20182 | Propilot | Stock | 0mph | 0mph | +| Nissan | Leaf 2018-192 | Propilot | Stock | 0mph | 0mph | +| Nissan | Rogue 20192 | Propilot | Stock | 0mph | 0mph | | Nissan | X-Trail 20172 | Propilot | Stock | 0mph | 0mph | | Subaru | Crosstrek 2018-19 | EyeSight | Stock | 0mph | 0mph | | Subaru | Impreza 2018-20 | EyeSight | Stock | 0mph | 0mph | diff --git a/selfdrive/car/nissan/carcontroller.py b/selfdrive/car/nissan/carcontroller.py index 56e2ae752..5d988cb93 100644 --- a/selfdrive/car/nissan/carcontroller.py +++ b/selfdrive/car/nissan/carcontroller.py @@ -65,7 +65,7 @@ class CarController(): # send acc cancel cmd if drive is disabled but pcm is still on, or if the system can't be activated cruise_cancel = 1 - if self.CP.carFingerprint == CAR.XTRAIL and cruise_cancel: + if self.CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL] and cruise_cancel: can_sends.append(nissancan.create_acc_cancel_cmd(self.packer, CS.cruise_throttle_msg, frame)) # TODO: Find better way to cancel! diff --git a/selfdrive/car/nissan/carstate.py b/selfdrive/car/nissan/carstate.py index 849e89b73..45156a8cb 100644 --- a/selfdrive/car/nissan/carstate.py +++ b/selfdrive/car/nissan/carstate.py @@ -17,19 +17,19 @@ class CarState(CarStateBase): def update(self, cp, cp_adas, cp_cam): ret = car.CarState.new_message() - if self.CP.carFingerprint == CAR.XTRAIL: + if self.CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL]: ret.gas = cp.vl["GAS_PEDAL"]["GAS_PEDAL"] elif self.CP.carFingerprint == CAR.LEAF: ret.gas = cp.vl["CRUISE_THROTTLE"]["GAS_PEDAL"] ret.gasPressed = bool(ret.gas > 3) - if self.CP.carFingerprint == CAR.XTRAIL: + if self.CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL]: ret.brakePressed = bool(cp.vl["DOORS_LIGHTS"]["USER_BRAKE_PRESSED"]) elif self.CP.carFingerprint == CAR.LEAF: ret.brakePressed = bool(cp.vl["BRAKE_PEDAL"]["BRAKE_PEDAL"] > 3) - if self.CP.carFingerprint == CAR.XTRAIL: + if self.CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL]: ret.brakeLights = bool(cp.vl["DOORS_LIGHTS"]["BRAKE_LIGHT"]) ret.wheelSpeeds.fl = cp.vl["WHEEL_SPEEDS_FRONT"]["WHEEL_SPEED_FL"] * CV.KPH_TO_MS @@ -43,7 +43,7 @@ class CarState(CarStateBase): ret.standstill = ret.vEgoRaw < 0.01 ret.cruiseState.enabled = bool(cp_adas.vl["CRUISE_STATE"]["CRUISE_ENABLED"]) - if self.CP.carFingerprint == CAR.XTRAIL: + if self.CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL]: ret.cruiseState.available = bool(cp_cam.vl["PRO_PILOT"]["CRUISE_ON"]) elif self.CP.carFingerprint == CAR.LEAF: ret.cruiseState.available = bool(cp.vl["CRUISE_THROTTLE"]["CRUISE_AVAILABLE"]) @@ -54,6 +54,8 @@ class CarState(CarStateBase): if speed != 255: if self.CP.carFingerprint == CAR.XTRAIL: conversion = CV.KPH_TO_MS + elif self.CP.carFingerprint == CAR.ROGUE: + conversion = CV.MPH_TO_MS else: conversion = CV.MPH_TO_MS if cp.vl["HUD_SETTINGS"]["SPEED_MPH"] else CV.KPH_TO_MS speed -= 1 # Speed on HUD is always 1 lower than actually sent on can bus @@ -129,7 +131,7 @@ class CarState(CarStateBase): ("DOORS_LIGHTS", 10), ] - if CP.carFingerprint == CAR.XTRAIL: + if CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL]: signals += [ ("USER_BRAKE_PRESSED", "DOORS_LIGHTS", 1), ("BRAKE_LIGHT", "DOORS_LIGHTS", 1), @@ -271,7 +273,7 @@ class CarState(CarStateBase): @staticmethod def get_cam_can_parser(CP): signals = [] - if CP.carFingerprint == CAR.XTRAIL: + if CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL]: signals += [ ("CRUISE_ON", "PRO_PILOT", 0), ] diff --git a/selfdrive/car/nissan/interface.py b/selfdrive/car/nissan/interface.py index 34aeb13e6..319228da3 100644 --- a/selfdrive/car/nissan/interface.py +++ b/selfdrive/car/nissan/interface.py @@ -34,7 +34,7 @@ class CarInterface(CarInterfaceBase): ret.steerMaxBP = [0.] # m/s ret.steerMaxV = [1.] - if candidate == CAR.XTRAIL: + if candidate in [CAR.ROGUE, CAR.XTRAIL]: ret.mass = 1610 + STD_CARGO_KG ret.wheelbase = 2.705 ret.centerToFront = ret.wheelbase * 0.44 diff --git a/selfdrive/car/nissan/values.py b/selfdrive/car/nissan/values.py index 96777e5a4..4d1d1b932 100644 --- a/selfdrive/car/nissan/values.py +++ b/selfdrive/car/nissan/values.py @@ -5,6 +5,7 @@ STEER_THRESHOLD = 1.0 class CAR: XTRAIL = "NISSAN X-TRAIL 2017" LEAF = "NISSAN LEAF 2018" + ROGUE = "NISSAN ROGUE 2019" FINGERPRINTS = { @@ -18,12 +19,18 @@ FINGERPRINTS = { ], CAR.LEAF: [ { - 2: 5, 42: 6, 264: 3, 361: 8, 372: 8, 384: 8, 389: 8, 403: 8, 459: 7, 460: 4, 470: 8, 520: 1, 569: 8, 581: 8, 634: 7, 640: 8, 644: 8, 645: 8, 646: 5, 658: 8, 682: 8, 683: 8, 689: 8, 724: 6, 758: 3, 761: 2, 783: 3, 852: 8, 853: 8, 856: 8, 861: 8, 944: 1, 976: 6, 1008: 7, 1011: 7, 1057: 3, 1227: 8, 1228: 8, 1261: 5, 1342: 1, 1354: 8, 1361: 8, 1459: 8, 1477: 8, 1497: 3, 1549: 8, 1573: 6, 1821: 8, 1837: 8, 1856: 8, 1859: 8, 1861: 8, 1864: 8, 1874: 8, 1888: 8, 1891: 8, 1893: 8, 1906: 8, 1947: 8, 1949: 8, 1979: 8, 1981: 8, 2016: 8, 2017: 8, 2021: 8 + 2: 5, 42: 6, 264: 3, 361: 8, 372: 8, 384: 8, 389: 8, 403: 8, 459: 7, 460: 4, 470: 8, 520: 1, 569: 8, 581: 8, 634: 7, 640: 8, 644: 8, 645: 8, 646: 5, 658: 8, 682: 8, 683: 8, 689: 8, 724: 6, 758: 3, 761: 2, 783: 3, 852: 8, 853: 8, 856: 8, 861: 8, 944: 1, 976: 6, 1008: 7, 1011: 7, 1057: 3, 1227: 8, 1228: 8, 1261: 5, 1342: 1, 1354: 8, 1361: 8, 1459: 8, 1477: 8, 1497: 3, 1549: 8, 1573: 6, 1821: 8, 1837: 8, 1856: 8, 1859: 8, 1861: 8, 1864: 8, 1874: 8, 1888: 8, 1891: 8, 1893: 8, 1906: 8, 1947: 8, 1949: 8, 1979: 8, 1981: 8, 2016: 8, 2017: 8, 2021: 8, 643: 5, 1792: 8, 1872: 8, 1937: 8, 1953: 8, 1968: 8, 1988: 8, 2000: 8, 2001: 8, 2004: 8, 2005: 8, 2015: 8 }, ], + CAR.ROGUE: [ + { + 2: 5, 42: 6, 346: 6, 347: 5, 348: 8, 361: 8, 386: 8, 389: 8, 397: 8, 398: 8, 403: 8, 520: 2, 523: 6, 548: 8, 634: 7, 643: 5, 645: 8, 658: 8, 665: 8, 666: 8, 674: 2, 682: 8, 683: 8, 689: 8, 723: 8, 758: 3, 772: 8, 773: 6, 774: 7, 775: 8, 776: 6, 777: 7, 778: 6, 783: 3, 851: 8, 855: 8, 1041: 8, 1042: 8, 1055: 2, 1104: 4, 1105: 6, 1107: 4, 1108: 8, 1110: 7, 1111: 7, 1227: 8, 1228: 8, 1247: 4, 1266: 8, 1273: 7, 1342: 1, 1376: 6, 1401: 8, 1474: 2, 1497: 3, 1534: 7, 1821: 8, 1823: 8, 1837: 8, 1839: 8 + }, + ] } DBC = { CAR.XTRAIL: dbc_dict('nissan_x_trail_2017', None), CAR.LEAF: dbc_dict('nissan_leaf_2018', None), + CAR.ROGUE: dbc_dict('nissan_x_trail_2017', None), } diff --git a/selfdrive/test/test_car_models.py b/selfdrive/test/test_car_models.py index 868115fb7..69b376ee9 100755 --- a/selfdrive/test/test_car_models.py +++ b/selfdrive/test/test_car_models.py @@ -367,6 +367,10 @@ routes = { 'carFingerprint': MAZDA.CX5, 'enableCamera': True, }, + "059ab9162e23198e|2020-05-30--09-41-01": { + 'carFingerprint': NISSAN.ROGUE, + 'enableCamera': True, + }, } passive_routes: List[str] = [