From 4c1df131bb7209cc1a3814887b42095d20a484ea Mon Sep 17 00:00:00 2001 From: Andrew Frahn Date: Sat, 26 Jan 2019 22:41:08 +1100 Subject: [PATCH 1/4] Hyundai Kona 2019 with no SCC In Testing --- selfdrive/car/hyundai/carstate.py | 11 ++++++----- selfdrive/car/hyundai/interface.py | 8 ++++++++ selfdrive/car/hyundai/values.py | 12 +++++++++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index 01fd28a5876d79..182f47625f8e6e 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -1,4 +1,4 @@ -from selfdrive.car.hyundai.values import DBC, STEER_THRESHOLD +from selfdrive.car.hyundai.values import DBC, STEER_THRESHOLD, FEATURES from selfdrive.can.parser import CANParser from selfdrive.config import Conversions as CV from common.kalman.simple_kalman import KF1D @@ -50,6 +50,7 @@ def get_can_parser(CP): ("CF_Clu_InhibitR", "CLU15", 0), ("CF_Lvr_Gear","LVR12",0), + ("CF_Lvr_CruiseSet", "LVR12", 0), ("ACCEnable", "TCS13", 0), ("ACC_REQ", "TCS13", 0), @@ -158,7 +159,7 @@ def update(self, cp, cp_cam): self.park_brake = cp.vl["CGW1"]['CF_Gway_ParkBrakeSw'] self.main_on = True - self.acc_active = cp.vl["SCC12"]['ACCMode'] != 0 + self.acc_active = (cp.vl["LVR12"]["CF_Lvr_CruiseSet"] > 1) if self.car_fingerprint in FEATURES["no_scc"] else cp.vl["SCC12"]['ACCMode'] != 0 self.pcm_acc_status = int(self.acc_active) # calc best v_ego estimate, by averaging two opposite corners @@ -180,7 +181,7 @@ def update(self, cp, cp_cam): self.a_ego = float(v_ego_x[1]) is_set_speed_in_mph = int(cp.vl["CLU11"]["CF_Clu_SPEED_UNIT"]) speed_conv = CV.MPH_TO_MS if is_set_speed_in_mph else CV.KPH_TO_MS - self.cruise_set_speed = cp.vl["SCC11"]['VSetDis'] * speed_conv + self.cruise_set_speed = cp.vl["LVR12"]["CF_Lvr_CruiseSet"] * speed_conv if self.car_fingerprint in FEATURES["no_scc"] else cp.vl["SCC11"]['VSetDis'] * speed_conv self.standstill = not self.v_wheel > 0.1 self.angle_steers = cp.vl["SAS11"]['SAS_Angle'] @@ -197,13 +198,13 @@ def update(self, cp, cp_cam): self.brake_error = 0 self.steer_torque_driver = cp.vl["MDPS11"]['CR_Mdps_DrvTq'] self.steer_torque_motor = cp.vl["MDPS12"]['CR_Mdps_OutTq'] - self.stopped = cp.vl["SCC11"]['SCCInfoDisplay'] == 4. + self.stopped = False if self.car_fingerprint in FEATURES["no_scc"] else cp.vl["SCC11"]['SCCInfoDisplay'] == 4. self.user_brake = 0 self.brake_pressed = cp.vl["TCS13"]['DriverBraking'] self.brake_lights = bool(self.brake_pressed) - if (cp.vl["TCS13"]["DriverOverride"] == 0 and cp.vl["TCS13"]['ACC_REQ'] == 1): + if (cp.vl["TCS13"]["DriverOverride"] == 0 and (cp.vl["TCS13"]['ACC_REQ'] == 1 or self.car_fingerprint in FEATURES["no_scc"])): self.pedal_gas = 0 else: self.pedal_gas = cp.vl["EMS12"]['TPS'] diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index 5399d827610896..303453829534e1 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -122,6 +122,14 @@ def get_params(candidate, fingerprint): ret.steerKiBP, ret.steerKpBP = [[0.], [0.]] ret.steerKpV, ret.steerKiV = [[0.25], [0.05]] ret.minSteerSpeed = 0. + elif candidate == CAR.KONA: + ret.steerKf = 0.00005 + ret.mass = 1360 + ret.wheelbase = 2.601 + ret.steerRatio = 12.916 + tire_stiffness_factor = 0.5 + ret.steerKiBP, ret.steerKpBP = [[0.], [0.]] + ret.steerKpV, ret.steerKiV = [[0.25], [0.05]] ret.minEnableSpeed = -1. # enable is done by stock ACC, so ignore this ret.longitudinalKpBP = [0.] diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index 56b6e605361b5e..a20194a7180971 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -16,6 +16,7 @@ class CAR: KIA_SORENTO = "KIA SORENTO GT LINE 2018" KIA_STINGER = "KIA STINGER GT2 2018" SANTA_FE = "HYUNDAI SANTA FE LIMITED 2019" + KONA = "HYUNDAI KONA 2019" class Buttons: NONE = 0 @@ -46,6 +47,9 @@ class Buttons: 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 6, 764: 8, 809: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1155: 8, 1162: 8, 1164: 8, 1168: 7, 1170: 8, 1173: 8, 1180: 8, 1183: 8, 1186: 2, 1227: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 8, 1384: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8, 1988: 8, 2000: 8, 2004: 8, 2008: 8, 2012: 8 } ], + CAR.KONA: [{ + 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 354: 3, 356: 4, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 909: 8, 916: 8, 1040: 8, 1078: 4, 1107: 5, 1136: 8, 1156: 8, 1170: 8, 1173: 8, 1191: 2, 1265: 4, 1280: 1, 1287: 4, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1384: 8, 1394: 8,1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8, 2004: 8, 2009: 8, 2012: 8 + }], } CAMERA_MSGS = [832, 1156, 1191, 1342] @@ -53,7 +57,12 @@ class Buttons: CHECKSUM = { "crc8": [CAR.SANTA_FE], "6B": [CAR.KIA_SORENTO, CAR.GENESIS], - "7B": [CAR.KIA_STINGER, CAR.ELANTRA], + "7B": [CAR.KIA_STINGER, CAR.ELANTRA, CAR.KONA], +} + +# Lane Keep Assist related Features and Limitations +FEATURES = { + "no_scc": [CAR.KONA], } DBC = { @@ -62,6 +71,7 @@ class Buttons: CAR.KIA_SORENTO: dbc_dict('hyundai_kia_generic', None), CAR.KIA_STINGER: dbc_dict('hyundai_kia_generic', None), CAR.SANTA_FE: dbc_dict('hyundai_kia_generic', None), + CAR.KONA: dbc_dict('hyundai_kia_generic', None), } STEER_THRESHOLD = 100 From 9757cdb43e3b9cb7110eac8bd9c8357d97138780 Mon Sep 17 00:00:00 2001 From: Andrew Frahn Date: Sun, 27 Jan 2019 21:37:52 +1100 Subject: [PATCH 2/4] Update Readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5ef834ef4e6ae9..1fdc25c78213f9 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ Supported Cars | Hyundai | Santa Fe 2019 | All | Yes | Stock | 0mph | 0mph | Custom6| | Hyundai | Elantra 2017 | SCC + LKAS | Yes | Stock | 19mph | 34mph | Custom6| | Hyundai | Genesis 2018 | All | Yes | Stock | 19mph | 34mph | Custom6| +| Hyundai | Kona 2019 | LKAS | Yes | No9 | **WIP** | **WIP** | Custom6| | Kia | Sorento 2018 | All | Yes | Stock | 0mph | 0mph | Custom6| | Kia | Stinger 2018 | SCC + LKAS | Yes | Stock | 0mph | 0mph | Custom6| | Lexus | RX Hybrid 2016-18 | All | Yes | Yes2| 0mph | 0mph | Toyota | @@ -104,6 +105,7 @@ Supported Cars 6Open sourced [Hyundai Giraffe](https://github.com/commaai/neo/tree/master/giraffe/hyundai) is designed for the 2019 Sante Fe; pinout may differ for other Hyundais. 7Community built Giraffe, find more information [here](https://zoneos.com/shop/). 8Community built Giraffe, find more information [here](https://github.com/adhintz/openpilot/wiki). Comma official Giraffe coming soon. +9Car does not come with Smart/Adaptive Cruise Control. Open Pilot will only engage when Cruise is set, but will not adjust vehicle speed for traffic. Community Maintained Cars ------ From 1c68d03dea80fdcaca814220b2ed1ed14fdb8055 Mon Sep 17 00:00:00 2001 From: Andrew Frahn Date: Sun, 27 Jan 2019 21:46:20 +1100 Subject: [PATCH 3/4] Update DBC for Kona --- opendbc/hyundai_kia_generic.dbc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/opendbc/hyundai_kia_generic.dbc b/opendbc/hyundai_kia_generic.dbc index b9e654fa662bcb..2655d2da6ed203 100644 --- a/opendbc/hyundai_kia_generic.dbc +++ b/opendbc/hyundai_kia_generic.dbc @@ -692,6 +692,7 @@ BO_ 1365 FPCM11: 8 FPCM SG_ CF_Fpcm_LPCtrCirFlt : 15|1@1+ (1.0,0.0) [0.0|1.0] "" EMS BO_ 871 LVR12: 8 LVR + SG_ CF_Lvr_CruiseSet : 7|8@1+ (1.0,0.0) [0.0|255.0] "" CLU,TCU SG_ CF_Lvr_Gear : 32|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,TCU BO_ 872 LVR11: 8 LVR @@ -896,11 +897,11 @@ BO_ 67 DATC13: 8 DATC BO_ 66 DATC12: 8 DATC SG_ CR_Datc_DrTempDispC : 0|8@1+ (0.5,14.0) [15.0|32.0] "deg" CLU,IBOX - SG_ CR_Datc_DrTempDispF : 8|8@1+ (1.0,56.0) [58.0|90.0] "¢µ" CLU,IBOX + SG_ CR_Datc_DrTempDispF : 8|8@1+ (1.0,56.0) [58.0|90.0] "deg" CLU,IBOX SG_ CR_Datc_PsTempDispC : 16|8@1+ (0.5,14.0) [15.0|32.0] "deg" CLU,IBOX - SG_ CR_Datc_PsTempDispF : 24|8@1+ (1.0,56.0) [58.0|90.0] "¢µ" CLU,IBOX + SG_ CR_Datc_PsTempDispF : 24|8@1+ (1.0,56.0) [58.0|90.0] "deg" CLU,IBOX SG_ CR_Datc_RearDrTempDispC : 40|8@1+ (0.5,14.0) [15.0|32.0] "deg" CLU - SG_ CR_Datc_RearDrTempDispF : 48|8@1+ (1.0,58.0) [58.0|90.0] "¢µ" CLU + SG_ CR_Datc_RearDrTempDispF : 48|8@1+ (1.0,58.0) [58.0|90.0] "deg" CLU SG_ CF_Datc_CO2_Warning : 56|8@1+ (1.0,0.0) [0.0|3.0] "" CLU BO_ 1345 CGW1: 8 BCM @@ -980,6 +981,8 @@ BO_ 832 LKAS11: 8 LDWS_LKAS SG_ CF_Lkas_Chksum : 48|8@1+ (1.0,0.0) [0.0|255.0] "" MDPS SG_ CF_Lkas_FcwOpt_USM : 56|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ CF_Lkas_LdwsOpt_USM : 59|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,MDPS + SG_ CF_Lkas_Unknown1 : 47|1@1+ (1,0) [0|3] "" XXX + SG_ CF_Lkas_Unknown2 : 63|2@0+ (1,0) [0|3] "" XXX BO_ 1342 LKAS12: 6 LDWS_LKAS SG_ CF_Lkas_TsrSlifOpt : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU From 6c1c7b6271ba91b4f88a8ebe41f1d583ab9c9bc5 Mon Sep 17 00:00:00 2001 From: Andrew Frahn Date: Sun, 27 Jan 2019 21:57:49 +1100 Subject: [PATCH 4/4] fix offset --- opendbc/hyundai_kia_generic.dbc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opendbc/hyundai_kia_generic.dbc b/opendbc/hyundai_kia_generic.dbc index 2655d2da6ed203..e3e6a1eb6118cb 100644 --- a/opendbc/hyundai_kia_generic.dbc +++ b/opendbc/hyundai_kia_generic.dbc @@ -692,7 +692,7 @@ BO_ 1365 FPCM11: 8 FPCM SG_ CF_Fpcm_LPCtrCirFlt : 15|1@1+ (1.0,0.0) [0.0|1.0] "" EMS BO_ 871 LVR12: 8 LVR - SG_ CF_Lvr_CruiseSet : 7|8@1+ (1.0,0.0) [0.0|255.0] "" CLU,TCU + SG_ CF_Lvr_CruiseSet : 0|8@1+ (1.0,0.0) [0.0|255.0] "" CLU,TCU SG_ CF_Lvr_Gear : 32|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,TCU BO_ 872 LVR11: 8 LVR