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

Hyundai Kona 2019 with no SCC #514

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Supported Cars
| Hyundai | Santa Fe 2019 | All | Yes | Stock | 0mph | 0mph | Custom<sup>6</sup>|
| Hyundai | Elantra 2017 | SCC + LKAS | Yes | Stock | 19mph | 34mph | Custom<sup>6</sup>|
| Hyundai | Genesis 2018 | All | Yes | Stock | 19mph | 34mph | Custom<sup>6</sup>|
| Hyundai | Kona 2019 | LKAS | Yes | No<sup>9</sup> | **WIP** | **WIP** | Custom<sup>6</sup>|
| Kia | Sorento 2018 | All | Yes | Stock | 0mph | 0mph | Custom<sup>6</sup>|
| Kia | Stinger 2018 | SCC + LKAS | Yes | Stock | 0mph | 0mph | Custom<sup>6</sup>|
| Lexus | RX Hybrid 2016-18 | All | Yes | Yes<sup>2</sup>| 0mph | 0mph | Toyota |
Expand All @@ -104,6 +105,7 @@ Supported Cars
<sup>6</sup>Open 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.
<sup>7</sup>Community built Giraffe, find more information [here](https://zoneos.com/shop/).
<sup>8</sup>Community built Giraffe, find more information [here](https://github.com/adhintz/openpilot/wiki). Comma official Giraffe coming soon.
<sup>9</sup>Car 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
------
Expand Down
9 changes: 6 additions & 3 deletions opendbc/hyundai_kia_generic.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -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 : 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions selfdrive/car/hyundai/carstate.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand All @@ -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']
Expand All @@ -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']
Expand Down
8 changes: 8 additions & 0 deletions selfdrive/car/hyundai/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.]
Expand Down
12 changes: 11 additions & 1 deletion selfdrive/car/hyundai/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,14 +47,22 @@ 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]

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 = {
Expand All @@ -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