Skip to content

Commit 925f82c

Browse files
Hyundai: Car Port for Kona 2022 (commaai#1137)
* Hyundai: Car Port for Kona 2022 * alt steering 2 with 170 * add test route * remove abs and engine fw * no date platform * point to feature branch to pass unit test for now * another user's FW * new test route * add back flag * migrate safety and safety tests to opendbc * dashcam it --------- Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
1 parent 3754dcf commit 925f82c

10 files changed

Lines changed: 59 additions & 2 deletions

File tree

opendbc/car/hyundai/fingerprints.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,4 +1216,19 @@
12161216
b'\xf1\x00FE__ SCC FHCUP 1.00 1.05 99110-M5000 ',
12171217
],
12181218
},
1219+
CAR.HYUNDAI_KONA_2022: {
1220+
(Ecu.fwdCamera, 0x7C4, None): [
1221+
b'\xf1\x00OSP LKA AT USA LHD 1.00 1.04 99211-J9200 904',
1222+
],
1223+
(Ecu.eps, 0x7D4, None): [
1224+
b'\xf1\x00OSP MDPS C 1.00 1.04 56310/J9291 4OPCC104',
1225+
],
1226+
(Ecu.fwdRadar, 0x7D0, None): [
1227+
b'\xf1\x00YB__ FCA ----- 1.00 1.01 99110-J9000 \x00\x00\x00',
1228+
],
1229+
(Ecu.transmission, 0x7e1, None): [
1230+
b'\xf1\x00T01G00BL T01I00A1 DOS2T16X4XI00NS0\x99L\xeeq',
1231+
b'\xf1\x00T01G00BL T01I00A1 DOS2T16X2XI00NS0\x8c`\xff\xe7',
1232+
],
1233+
},
12191234
}

opendbc/car/hyundai/hyundaican.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def create_lkas11(packer, frame, CP, apply_steer, steer_req,
3838
CAR.HYUNDAI_ELANTRA_HEV_2021, CAR.HYUNDAI_SONATA_HYBRID, CAR.HYUNDAI_KONA_EV, CAR.HYUNDAI_KONA_HEV, CAR.HYUNDAI_KONA_EV_2022,
3939
CAR.HYUNDAI_SANTA_FE_2022, CAR.KIA_K5_2021, CAR.HYUNDAI_IONIQ_HEV_2022, CAR.HYUNDAI_SANTA_FE_HEV_2022,
4040
CAR.HYUNDAI_SANTA_FE_PHEV_2022, CAR.KIA_STINGER_2022, CAR.KIA_K5_HEV_2020, CAR.KIA_CEED,
41-
CAR.HYUNDAI_AZERA_6TH_GEN, CAR.HYUNDAI_AZERA_HEV_6TH_GEN, CAR.HYUNDAI_CUSTIN_1ST_GEN):
41+
CAR.HYUNDAI_AZERA_6TH_GEN, CAR.HYUNDAI_AZERA_HEV_6TH_GEN, CAR.HYUNDAI_CUSTIN_1ST_GEN, CAR.HYUNDAI_KONA_2022):
4242
values["CF_Lkas_LdwsActivemode"] = int(left_lane) + (int(right_lane) << 1)
4343
values["CF_Lkas_LdwsOpt_USM"] = 2
4444

opendbc/car/hyundai/interface.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experime
104104
if ret.flags & HyundaiFlags.ALT_LIMITS:
105105
ret.safetyConfigs[-1].safetyParam |= HyundaiSafetyFlags.ALT_LIMITS.value
106106

107+
if ret.flags & HyundaiFlags.ALT_LIMITS_2:
108+
ret.safetyConfigs[-1].safetyParam |= HyundaiSafetyFlags.ALT_LIMITS_2.value
109+
110+
# see https://github.com/commaai/opendbc/pull/1137/
111+
ret.dashcamOnly = True
112+
107113
# Common longitudinal control setup
108114

109115
ret.radarUnavailable = RADAR_START_ADDR not in fingerprint[1] or Bus.radar not in DBC[ret.carFingerprint]

opendbc/car/hyundai/tests/test_hyundai.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
CAR.HYUNDAI_KONA_HEV,
3838
CAR.HYUNDAI_SONATA_LF,
3939
CAR.HYUNDAI_VELOSTER,
40+
CAR.HYUNDAI_KONA_2022,
4041
}
4142

4243
CANFD_EXPECTED_ECUS = {Ecu.fwdCamera, Ecu.fwdRadar}

opendbc/car/hyundai/values.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ def __init__(self, CP):
4545
self.STEER_DELTA_UP = 2
4646
self.STEER_DELTA_DOWN = 3
4747

48+
elif CP.flags & HyundaiFlags.ALT_LIMITS_2:
49+
self.STEER_MAX = 170
50+
self.STEER_DELTA_UP = 2
51+
self.STEER_DELTA_DOWN = 3
52+
4853
# Default for most HKG
4954
else:
5055
self.STEER_MAX = 384
@@ -60,6 +65,7 @@ class HyundaiSafetyFlags(IntFlag):
6065
ALT_LIMITS = 64
6166
CANFD_LKA_STEERING_ALT = 128
6267
FCEV_GAS = 256
68+
ALT_LIMITS_2 = 512
6369

6470

6571
class HyundaiFlags(IntFlag):
@@ -118,6 +124,8 @@ class HyundaiFlags(IntFlag):
118124

119125
FCEV = 2 ** 25
120126

127+
ALT_LIMITS_2 = 2 ** 26
128+
121129

122130
class Footnote(Enum):
123131
CANFD = CarFootnote(
@@ -242,6 +250,11 @@ class CAR(Platforms):
242250
CarSpecs(mass=1275, wheelbase=2.6, steerRatio=13.42, tireStiffnessFactor=0.385),
243251
flags=HyundaiFlags.CLUSTER_GEARS | HyundaiFlags.ALT_LIMITS,
244252
)
253+
HYUNDAI_KONA_2022 = HyundaiPlatformConfig(
254+
[HyundaiCarDocs("Hyundai Kona 2022", car_parts=CarParts.common([CarHarness.hyundai_o]))],
255+
CarSpecs(mass=1491, wheelbase=2.6, steerRatio=13.42, tireStiffnessFactor=0.385),
256+
flags=HyundaiFlags.CAMERA_SCC,
257+
)
245258
HYUNDAI_KONA_EV = HyundaiPlatformConfig(
246259
[HyundaiCarDocs("Hyundai Kona Electric 2018-21", car_parts=CarParts.common([CarHarness.hyundai_g]))],
247260
CarSpecs(mass=1685, wheelbase=2.6, steerRatio=13.42, tireStiffnessFactor=0.385),

opendbc/car/tests/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class CarTestRoute(NamedTuple):
155155
CarTestRoute("012c95f06918eca4|2023-01-15--11-19-36", HYUNDAI.HYUNDAI_IONIQ), # openpilot longitudinal enabled
156156
CarTestRoute("ab59fe909f626921|2021-10-18--18-34-28", HYUNDAI.HYUNDAI_IONIQ_HEV_2022),
157157
CarTestRoute("22d955b2cd499c22|2020-08-10--19-58-21", HYUNDAI.HYUNDAI_KONA),
158+
CarTestRoute("0099bdb24d82951b/00000005--c38d940b04", HYUNDAI.HYUNDAI_KONA_2022),
158159
CarTestRoute("efc48acf44b1e64d|2021-05-28--21-05-04", HYUNDAI.HYUNDAI_KONA_EV),
159160
CarTestRoute("f90d3cd06caeb6fa|2023-09-06--17-15-47", HYUNDAI.HYUNDAI_KONA_EV), # openpilot longitudinal enabled
160161
CarTestRoute("ff973b941a69366f|2022-07-28--22-01-19", HYUNDAI.HYUNDAI_KONA_EV_2022, segment=11),

opendbc/car/torque_data/substitute.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ legend = ["LAT_ACCEL_FACTOR", "MAX_LAT_ACCEL_MEASURED", "FRICTION"]
2929
"KIA_NIRO_HEV_2021" = "KIA_NIRO_EV"
3030
"HYUNDAI_VELOSTER" = "HYUNDAI_SONATA_LF"
3131
"HYUNDAI_KONA" = "HYUNDAI_KONA_EV"
32+
"HYUNDAI_KONA_2022" = "HYUNDAI_KONA_EV"
3233
"HYUNDAI_KONA_HEV" = "HYUNDAI_KONA_EV"
3334
"HYUNDAI_KONA_EV_2022" = "HYUNDAI_KONA_EV"
3435
"HYUNDAI_IONIQ" = "HYUNDAI_IONIQ_PHEV_2019"

opendbc/safety/safety/safety_hyundai.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ static void hyundai_rx_hook(const CANPacket_t *to_push) {
178178
static bool hyundai_tx_hook(const CANPacket_t *to_send) {
179179
const SteeringLimits HYUNDAI_STEERING_LIMITS = HYUNDAI_LIMITS(384, 3, 7);
180180
const SteeringLimits HYUNDAI_STEERING_LIMITS_ALT = HYUNDAI_LIMITS(270, 2, 3);
181+
const SteeringLimits HYUNDAI_STEERING_LIMITS_ALT_2 = HYUNDAI_LIMITS(170, 2, 3);
181182

182183
bool tx = true;
183184
int addr = GET_ADDR(to_send);
@@ -218,7 +219,9 @@ static bool hyundai_tx_hook(const CANPacket_t *to_send) {
218219
int desired_torque = ((GET_BYTES(to_send, 0, 4) >> 16) & 0x7ffU) - 1024U;
219220
bool steer_req = GET_BIT(to_send, 27U);
220221

221-
const SteeringLimits limits = hyundai_alt_limits ? HYUNDAI_STEERING_LIMITS_ALT : HYUNDAI_STEERING_LIMITS;
222+
const SteeringLimits limits = hyundai_alt_limits_2 ? HYUNDAI_STEERING_LIMITS_ALT_2 :
223+
hyundai_alt_limits ? HYUNDAI_STEERING_LIMITS_ALT : HYUNDAI_STEERING_LIMITS;
224+
222225
if (steer_torque_cmd_checks(desired_torque, steer_req, limits)) {
223226
tx = false;
224227
}

opendbc/safety/safety/safety_hyundai_common.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ bool hyundai_alt_limits = false;
3939
extern bool hyundai_fcev_gas_signal;
4040
bool hyundai_fcev_gas_signal = false;
4141

42+
extern bool hyundai_alt_limits_2;
43+
bool hyundai_alt_limits_2 = false;
44+
4245
static uint8_t hyundai_last_button_interaction; // button messages since the user pressed an enable button
4346

4447
void hyundai_common_init(uint16_t param) {
@@ -48,13 +51,15 @@ void hyundai_common_init(uint16_t param) {
4851
const int HYUNDAI_PARAM_CANFD_LKA_STEERING = 16;
4952
const int HYUNDAI_PARAM_ALT_LIMITS = 64; // TODO: shift this down with the rest of the common flags
5053
const int HYUNDAI_PARAM_FCEV_GAS = 256;
54+
const int HYUNDAI_PARAM_ALT_LIMITS_2 = 512;
5155

5256
hyundai_ev_gas_signal = GET_FLAG(param, HYUNDAI_PARAM_EV_GAS);
5357
hyundai_hybrid_gas_signal = !hyundai_ev_gas_signal && GET_FLAG(param, HYUNDAI_PARAM_HYBRID_GAS);
5458
hyundai_camera_scc = GET_FLAG(param, HYUNDAI_PARAM_CAMERA_SCC);
5559
hyundai_canfd_lka_steering = GET_FLAG(param, HYUNDAI_PARAM_CANFD_LKA_STEERING);
5660
hyundai_alt_limits = GET_FLAG(param, HYUNDAI_PARAM_ALT_LIMITS);
5761
hyundai_fcev_gas_signal = GET_FLAG(param, HYUNDAI_PARAM_FCEV_GAS);
62+
hyundai_alt_limits_2 = GET_FLAG(param, HYUNDAI_PARAM_ALT_LIMITS_2);
5863

5964
hyundai_last_button_interaction = HYUNDAI_PREV_BUTTON_SAMPLES;
6065

opendbc/safety/tests/test_hyundai.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,18 @@ def setUp(self):
127127
self.safety.init_tests()
128128

129129

130+
class TestHyundaiSafetyAltLimits2(TestHyundaiSafety):
131+
MAX_RATE_UP = 2
132+
MAX_RATE_DOWN = 3
133+
MAX_TORQUE = 170
134+
135+
def setUp(self):
136+
self.packer = CANPackerPanda("hyundai_kia_generic")
137+
self.safety = libsafety_py.libsafety
138+
self.safety.set_safety_hooks(CarParams.SafetyModel.hyundai, HyundaiSafetyFlags.ALT_LIMITS_2)
139+
self.safety.init_tests()
140+
141+
130142
class TestHyundaiSafetyCameraSCC(TestHyundaiSafety):
131143
BUTTONS_TX_BUS = 2 # tx on 2, rx on 0
132144
SCC_BUS = 2 # rx on 2

0 commit comments

Comments
 (0)