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

HKG: Car Port for Genesis G70 2024 #1134

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions opendbc/car/hyundai/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ def update(self, CC, CS, now_nanos):
if not self.CP.openpilotLongitudinalControl:
can_sends.extend(self.create_button_messages(CC, CS, use_clu11=True))

if self.frame % 7 and self.CP.flags & HyundaiFlags.CAMERA_SCC:
can_sends.append(hyundaican.create_hda11_mfc(self.packer, self.frame, CS.hda11_mfc))

if self.frame % 2 == 0 and self.CP.openpilotLongitudinalControl:
# TODO: unclear if this is needed
jerk = 3.0 if actuators.longControlState == LongCtrlState.pid else 1.0
Expand Down
6 changes: 5 additions & 1 deletion opendbc/car/hyundai/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,12 @@ def update(self, can_parsers) -> structs.CarState:
ret.leftBlindspot = cp.vl["LCA11"]["CF_Lca_IndLeft"] != 0
ret.rightBlindspot = cp.vl["LCA11"]["CF_Lca_IndRight"] != 0

# save the entire LKAS11 and CLU11
# save the entire LKAS11, CLU11, and HDA11_MFC
self.lkas11 = copy.copy(cp_cam.vl["LKAS11"])
self.clu11 = copy.copy(cp.vl["CLU11"])
if not self.CP.openpilotLongitudinalControl and self.CP.flags & HyundaiFlags.CAMERA_SCC:
self.hda11_mfc = copy.copy(cp_cam.vl["HDA11_MFC"])

self.steer_state = cp.vl["MDPS12"]["CF_Mdps_ToiActive"] # 0 NOT ACTIVE, 1 ACTIVE
prev_cruise_buttons = self.cruise_buttons[-1]
prev_main_buttons = self.main_buttons[-1]
Expand Down Expand Up @@ -376,6 +379,7 @@ def get_can_parsers(self, CP):
cam_messages += [
("SCC11", 50),
("SCC12", 50),
("HDA11_MFC", 14),
]

if CP.flags & HyundaiFlags.USE_FCA.value:
Expand Down
8 changes: 8 additions & 0 deletions opendbc/car/hyundai/fingerprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -1173,4 +1173,12 @@
b'\xf1\x00US4_ RDR ----- 1.00 1.00 99110-CG000 ',
],
},
CAR.GENESIS_G70_2024: {
(Ecu.fwdCamera, 0x7c4, None): [
b'\xf1\x00IK MFC AT USA LHD 1.00 1.02 99211-G9500 230712',
],
(Ecu.fwdRadar, 0x7d0, None): [
b'\xf1\x00IKPE RDR ----- 1.00 1.00 99110-G9600 ',
],
},
}
22 changes: 21 additions & 1 deletion opendbc/car/hyundai/hyundaican.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def create_lkas11(packer, frame, CP, apply_steer, steer_req,
CAR.HYUNDAI_ELANTRA_HEV_2021, CAR.HYUNDAI_SONATA_HYBRID, CAR.HYUNDAI_KONA_EV, CAR.HYUNDAI_KONA_HEV, CAR.HYUNDAI_KONA_EV_2022,
CAR.HYUNDAI_SANTA_FE_2022, CAR.KIA_K5_2021, CAR.HYUNDAI_IONIQ_HEV_2022, CAR.HYUNDAI_SANTA_FE_HEV_2022,
CAR.HYUNDAI_SANTA_FE_PHEV_2022, CAR.KIA_STINGER_2022, CAR.KIA_K5_HEV_2020, CAR.KIA_CEED,
CAR.HYUNDAI_AZERA_6TH_GEN, CAR.HYUNDAI_AZERA_HEV_6TH_GEN, CAR.HYUNDAI_CUSTIN_1ST_GEN):
CAR.HYUNDAI_AZERA_6TH_GEN, CAR.HYUNDAI_AZERA_HEV_6TH_GEN, CAR.HYUNDAI_CUSTIN_1ST_GEN, CAR.GENESIS_G70_2024):
values["CF_Lkas_LdwsActivemode"] = int(left_lane) + (int(right_lane) << 1)
values["CF_Lkas_LdwsOpt_USM"] = 2

Expand Down Expand Up @@ -117,12 +117,30 @@ def create_clu11(packer, frame, clu11, button, CP):
return packer.make_can_msg("CLU11", bus, values)


def create_hda11_mfc(packer, frame, hda11_mfc):
values = {s: hda11_mfc[s] for s in [
"Counter",
"NEW_SIGNAL_1",
"NEW_SIGNAL_2",
"NEW_SIGNAL_3",
"NEW_SIGNAL_5",
"NEW_SIGNAL_6",
"NEW_SIGNAL_7",
"NEW_SIGNAL_9",
]}
values["NEW_SIGNAL_4"] = 0x00
values["NEW_SIGNAL_8"] = 0x00
values["Counter"] = frame % 0x10
return packer.make_can_msg("HDA11_MFC", 0, values)


def create_lfahda_mfc(packer, enabled):
values = {
"LFA_Icon_State": 2 if enabled else 0,
}
return packer.make_can_msg("LFAHDA_MFC", 0, values)


def create_acc_commands(packer, enabled, accel, upper_jerk, idx, hud_control, set_speed, stopping, long_override, use_fca):
commands = []

Expand Down Expand Up @@ -184,6 +202,7 @@ def create_acc_commands(packer, enabled, accel, upper_jerk, idx, hud_control, se

return commands


def create_acc_opt(packer):
commands = []

Expand All @@ -203,6 +222,7 @@ def create_acc_opt(packer):

return commands


def create_frt_radar_opt(packer):
frt_radar11_values = {
"CF_FCA_Equip_Front_Radar": 1,
Expand Down
3 changes: 2 additions & 1 deletion opendbc/car/hyundai/tests/test_hyundai.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ def test_expected_platform_codes(self, subtests):
def test_platform_code_ecus_available(self, subtests):
# TODO: add queries for these non-CAN FD cars to get EPS
no_eps_platforms = CANFD_CAR | {CAR.KIA_SORENTO, CAR.KIA_OPTIMA_G4, CAR.KIA_OPTIMA_G4_FL, CAR.KIA_OPTIMA_H,
CAR.KIA_OPTIMA_H_G4_FL, CAR.HYUNDAI_SONATA_LF, CAR.HYUNDAI_TUCSON, CAR.GENESIS_G90, CAR.GENESIS_G80, CAR.HYUNDAI_ELANTRA}
CAR.KIA_OPTIMA_H_G4_FL, CAR.HYUNDAI_SONATA_LF, CAR.HYUNDAI_TUCSON, CAR.GENESIS_G90,
CAR.GENESIS_G80, CAR.HYUNDAI_ELANTRA, CAR.GENESIS_G70_2024}

# Asserts ECU keys essential for fuzzy fingerprinting are available on all platforms
for car_model, ecus in FW_VERSIONS.items():
Expand Down
5 changes: 5 additions & 0 deletions opendbc/car/hyundai/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,11 @@ class CAR(Platforms):
GENESIS_G70.specs,
flags=HyundaiFlags.MANDO_RADAR,
)
GENESIS_G70_2024 = HyundaiPlatformConfig(
[HyundaiCarDocs("Genesis G70 2024", "All", car_parts=CarParts.common([CarHarness.hyundai_l]))],
CarSpecs(mass=1769, wheelbase=2.83, steerRatio=12.9), # steerRatio guesstimate from G70 1st Gen platform
flags=HyundaiFlags.CHECKSUM_CRC8 | HyundaiFlags.CAMERA_SCC,
)
GENESIS_GV70_1ST_GEN = HyundaiCanFDPlatformConfig(
[
# TODO: Hyundai P is likely the correct harness for HDA II for 2.5T (unsupported due to missing ADAS ECU, is that the radar?)
Expand Down
1 change: 1 addition & 0 deletions opendbc/car/tests/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class CarTestRoute(NamedTuple):
CarTestRoute("715ac05b594e9c59|2021-06-20--16-21-07", HYUNDAI.HYUNDAI_ELANTRA_HEV_2021),
CarTestRoute("7120aa90bbc3add7|2021-08-02--07-12-31", HYUNDAI.HYUNDAI_SONATA_HYBRID),
CarTestRoute("715ac05b594e9c59|2021-10-27--23-24-56", HYUNDAI.GENESIS_G70_2020),
CarTestRoute("a6310918f9699ef5/2024-02-28--14-55-10", HYUNDAI.GENESIS_G70_2024), # 3.3T
CarTestRoute("6b0d44d22df18134|2023-05-06--10-36-55", HYUNDAI.GENESIS_GV80),

CarTestRoute("00c829b1b7613dea|2021-06-24--09-10-10", TOYOTA.TOYOTA_ALPHARD_TSS2),
Expand Down
1 change: 1 addition & 0 deletions opendbc/car/torque_data/override.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ legend = ["LAT_ACCEL_FACTOR", "MAX_LAT_ACCEL_MEASURED", "FRICTION"]
"HYUNDAI_STARIA_4TH_GEN" = [1.8, 2.0, 0.15]
"GENESIS_GV70_ELECTRIFIED_1ST_GEN" = [1.9, 1.9, 0.09]
"GENESIS_G80_2ND_GEN_FL" = [2.5819356441497803, 2.5, 0.11244568973779678]
"GENESIS_G70_2024" = [2.7, 2.7, 0.11]

# Dashcam or fallback configured as ideal car
"MOCK" = [10.0, 10, 0.0]
Expand Down
Loading