mirror of https://github.com/commaai/openpilot.git
Hyundai: rename HDA2 platform to CANFD (#25411)
* Hyundai: rename HDA2 platform to CANFD
* bump panda
* bump panda
* cleanup panda safety config
old-commit-hash: 5f35c669a6
This commit is contained in:
parent
d2de0b4e58
commit
c55b3fd7ee
2
cereal
2
cereal
|
@ -1 +1 @@
|
||||||
Subproject commit fbd45de6e6bc71b4561eaef65dd86fce952c5d55
|
Subproject commit 5ab19700178f01c14f362735532ee2662ab755fc
|
2
panda
2
panda
|
@ -1 +1 @@
|
||||||
Subproject commit 486af7950348530309778240f235fd75a30f1842
|
Subproject commit 06592b5c0e6f1aa83e4c8f95ecb1bf86b9277528
|
|
@ -4,8 +4,8 @@ from common.numpy_fast import clip, interp
|
||||||
from common.realtime import DT_CTRL
|
from common.realtime import DT_CTRL
|
||||||
from opendbc.can.packer import CANPacker
|
from opendbc.can.packer import CANPacker
|
||||||
from selfdrive.car import apply_std_steer_torque_limits
|
from selfdrive.car import apply_std_steer_torque_limits
|
||||||
from selfdrive.car.hyundai import hda2can, hyundaican
|
from selfdrive.car.hyundai import hyundaicanfd, hyundaican
|
||||||
from selfdrive.car.hyundai.values import Buttons, CarControllerParams, HDA2_CAR, CAR
|
from selfdrive.car.hyundai.values import Buttons, CarControllerParams, CANFD_CAR, CAR
|
||||||
|
|
||||||
VisualAlert = car.CarControl.HUDControl.VisualAlert
|
VisualAlert = car.CarControl.HUDControl.VisualAlert
|
||||||
LongCtrlState = car.CarControl.Actuators.LongControlState
|
LongCtrlState = car.CarControl.Actuators.LongControlState
|
||||||
|
@ -69,23 +69,23 @@ class CarController:
|
||||||
|
|
||||||
can_sends = []
|
can_sends = []
|
||||||
|
|
||||||
if self.CP.carFingerprint in HDA2_CAR:
|
if self.CP.carFingerprint in CANFD_CAR:
|
||||||
# steering control
|
# steering control
|
||||||
can_sends.append(hda2can.create_lkas(self.packer, CC.enabled, CC.latActive, apply_steer))
|
can_sends.append(hyundaicanfd.create_lkas(self.packer, CC.enabled, CC.latActive, apply_steer))
|
||||||
|
|
||||||
if self.frame % 5 == 0:
|
if self.frame % 5 == 0:
|
||||||
can_sends.append(hda2can.create_cam_0x2a4(self.packer, CS.cam_0x2a4))
|
can_sends.append(hyundaicanfd.create_cam_0x2a4(self.packer, CS.cam_0x2a4))
|
||||||
|
|
||||||
# cruise cancel
|
# cruise cancel
|
||||||
if (self.frame - self.last_button_frame) * DT_CTRL > 0.25:
|
if (self.frame - self.last_button_frame) * DT_CTRL > 0.25:
|
||||||
if CC.cruiseControl.cancel:
|
if CC.cruiseControl.cancel:
|
||||||
for _ in range(20):
|
for _ in range(20):
|
||||||
can_sends.append(hda2can.create_buttons(self.packer, CS.buttons_counter+1, Buttons.CANCEL))
|
can_sends.append(hyundaicanfd.create_buttons(self.packer, CS.buttons_counter+1, Buttons.CANCEL))
|
||||||
self.last_button_frame = self.frame
|
self.last_button_frame = self.frame
|
||||||
|
|
||||||
# cruise standstill resume
|
# cruise standstill resume
|
||||||
elif CC.cruiseControl.resume:
|
elif CC.cruiseControl.resume:
|
||||||
can_sends.append(hda2can.create_buttons(self.packer, CS.buttons_counter+1, Buttons.RES_ACCEL))
|
can_sends.append(hyundaicanfd.create_buttons(self.packer, CS.buttons_counter+1, Buttons.RES_ACCEL))
|
||||||
self.last_button_frame = self.frame
|
self.last_button_frame = self.frame
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ from cereal import car
|
||||||
from common.conversions import Conversions as CV
|
from common.conversions import Conversions as CV
|
||||||
from opendbc.can.parser import CANParser
|
from opendbc.can.parser import CANParser
|
||||||
from opendbc.can.can_define import CANDefine
|
from opendbc.can.can_define import CANDefine
|
||||||
from selfdrive.car.hyundai.values import DBC, FEATURES, CAMERA_SCC_CAR, HDA2_CAR, EV_CAR, HYBRID_CAR, Buttons, CarControllerParams
|
from selfdrive.car.hyundai.values import DBC, FEATURES, CAMERA_SCC_CAR, CANFD_CAR, EV_CAR, HYBRID_CAR, Buttons, CarControllerParams
|
||||||
from selfdrive.car.interfaces import CarStateBase
|
from selfdrive.car.interfaces import CarStateBase
|
||||||
|
|
||||||
PREV_BUTTON_SAMPLES = 8
|
PREV_BUTTON_SAMPLES = 8
|
||||||
|
@ -19,7 +19,7 @@ class CarState(CarStateBase):
|
||||||
self.cruise_buttons = deque([Buttons.NONE] * PREV_BUTTON_SAMPLES, maxlen=PREV_BUTTON_SAMPLES)
|
self.cruise_buttons = deque([Buttons.NONE] * PREV_BUTTON_SAMPLES, maxlen=PREV_BUTTON_SAMPLES)
|
||||||
self.main_buttons = deque([Buttons.NONE] * PREV_BUTTON_SAMPLES, maxlen=PREV_BUTTON_SAMPLES)
|
self.main_buttons = deque([Buttons.NONE] * PREV_BUTTON_SAMPLES, maxlen=PREV_BUTTON_SAMPLES)
|
||||||
|
|
||||||
if CP.carFingerprint in HDA2_CAR:
|
if CP.carFingerprint in CANFD_CAR:
|
||||||
self.shifter_values = can_define.dv["ACCELERATOR"]["GEAR"]
|
self.shifter_values = can_define.dv["ACCELERATOR"]["GEAR"]
|
||||||
elif self.CP.carFingerprint in FEATURES["use_cluster_gears"]:
|
elif self.CP.carFingerprint in FEATURES["use_cluster_gears"]:
|
||||||
self.shifter_values = can_define.dv["CLU15"]["CF_Clu_Gear"]
|
self.shifter_values = can_define.dv["CLU15"]["CF_Clu_Gear"]
|
||||||
|
@ -35,8 +35,8 @@ class CarState(CarStateBase):
|
||||||
self.params = CarControllerParams(CP)
|
self.params = CarControllerParams(CP)
|
||||||
|
|
||||||
def update(self, cp, cp_cam):
|
def update(self, cp, cp_cam):
|
||||||
if self.CP.carFingerprint in HDA2_CAR:
|
if self.CP.carFingerprint in CANFD_CAR:
|
||||||
return self.update_hda2(cp, cp_cam)
|
return self.update_canfd(cp, cp_cam)
|
||||||
|
|
||||||
ret = car.CarState.new_message()
|
ret = car.CarState.new_message()
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ class CarState(CarStateBase):
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def update_hda2(self, cp, cp_cam):
|
def update_canfd(self, cp, cp_cam):
|
||||||
ret = car.CarState.new_message()
|
ret = car.CarState.new_message()
|
||||||
|
|
||||||
ret.gas = cp.vl["ACCELERATOR"]["ACCELERATOR_PEDAL"] / 255.
|
ret.gas = cp.vl["ACCELERATOR"]["ACCELERATOR_PEDAL"] / 255.
|
||||||
|
@ -183,8 +183,8 @@ class CarState(CarStateBase):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_can_parser(CP):
|
def get_can_parser(CP):
|
||||||
if CP.carFingerprint in HDA2_CAR:
|
if CP.carFingerprint in CANFD_CAR:
|
||||||
return CarState.get_can_parser_hda2(CP)
|
return CarState.get_can_parser_canfd(CP)
|
||||||
|
|
||||||
signals = [
|
signals = [
|
||||||
# signal_name, signal_address
|
# signal_name, signal_address
|
||||||
|
@ -318,7 +318,7 @@ class CarState(CarStateBase):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_cam_can_parser(CP):
|
def get_cam_can_parser(CP):
|
||||||
if CP.carFingerprint in HDA2_CAR:
|
if CP.carFingerprint in CANFD_CAR:
|
||||||
signals = [(f"BYTE{i}", "CAM_0x2a4") for i in range(3, 24)]
|
signals = [(f"BYTE{i}", "CAM_0x2a4") for i in range(3, 24)]
|
||||||
checks = [("CAM_0x2a4", 20)]
|
checks = [("CAM_0x2a4", 20)]
|
||||||
return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 6)
|
return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 6)
|
||||||
|
@ -373,7 +373,7 @@ class CarState(CarStateBase):
|
||||||
return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 2)
|
return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 2)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_can_parser_hda2(CP):
|
def get_can_parser_canfd(CP):
|
||||||
signals = [
|
signals = [
|
||||||
("WHEEL_SPEED_1", "WHEEL_SPEEDS"),
|
("WHEEL_SPEED_1", "WHEEL_SPEEDS"),
|
||||||
("WHEEL_SPEED_2", "WHEEL_SPEEDS"),
|
("WHEEL_SPEED_2", "WHEEL_SPEEDS"),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from cereal import car
|
from cereal import car
|
||||||
from panda import Panda
|
from panda import Panda
|
||||||
from common.conversions import Conversions as CV
|
from common.conversions import Conversions as CV
|
||||||
from selfdrive.car.hyundai.values import CAR, DBC, CAMERA_SCC_CAR, EV_CAR, HYBRID_CAR, LEGACY_SAFETY_MODE_CAR, Buttons, CarControllerParams
|
from selfdrive.car.hyundai.values import CAR, DBC, CANFD_CAR, CAMERA_SCC_CAR, EV_CAR, HYBRID_CAR, LEGACY_SAFETY_MODE_CAR, Buttons, CarControllerParams
|
||||||
from selfdrive.car.hyundai.radar_interface import RADAR_START_ADDR
|
from selfdrive.car.hyundai.radar_interface import RADAR_START_ADDR
|
||||||
from selfdrive.car import STD_CARGO_KG, create_button_enable_events, create_button_event, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint, get_safety_config
|
from selfdrive.car import STD_CARGO_KG, create_button_enable_events, create_button_event, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint, get_safety_config
|
||||||
from selfdrive.car.interfaces import CarInterfaceBase
|
from selfdrive.car.interfaces import CarInterfaceBase
|
||||||
|
@ -25,7 +25,6 @@ class CarInterface(CarInterfaceBase):
|
||||||
ret = CarInterfaceBase.get_std_params(candidate, fingerprint)
|
ret = CarInterfaceBase.get_std_params(candidate, fingerprint)
|
||||||
|
|
||||||
ret.carName = "hyundai"
|
ret.carName = "hyundai"
|
||||||
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hyundai, 0)]
|
|
||||||
ret.radarOffCan = RADAR_START_ADDR not in fingerprint[1] or DBC[ret.carFingerprint]["radar"] is None
|
ret.radarOffCan = RADAR_START_ADDR not in fingerprint[1] or DBC[ret.carFingerprint]["radar"] is None
|
||||||
|
|
||||||
# WARNING: disabling radar also disables AEB (and we show the same warning on the instrument cluster as if you manually disabled AEB)
|
# WARNING: disabling radar also disables AEB (and we show the same warning on the instrument cluster as if you manually disabled AEB)
|
||||||
|
@ -238,8 +237,6 @@ class CarInterface(CarInterfaceBase):
|
||||||
ret.mass = 2055 + STD_CARGO_KG
|
ret.mass = 2055 + STD_CARGO_KG
|
||||||
ret.wheelbase = 2.9
|
ret.wheelbase = 2.9
|
||||||
ret.steerRatio = 16.
|
ret.steerRatio = 16.
|
||||||
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.noOutput),
|
|
||||||
get_safety_config(car.CarParams.SafetyModel.hyundaiHDA2)]
|
|
||||||
tire_stiffness_factor = 0.65
|
tire_stiffness_factor = 0.65
|
||||||
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
|
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
|
||||||
|
|
||||||
|
@ -279,15 +276,28 @@ class CarInterface(CarInterfaceBase):
|
||||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.01]]
|
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.01]]
|
||||||
|
|
||||||
# these cars require a special panda safety mode due to missing counters and checksums in the messages
|
# panda safety config
|
||||||
if candidate in LEGACY_SAFETY_MODE_CAR:
|
if candidate in CANFD_CAR:
|
||||||
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hyundaiLegacy)]
|
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.noOutput),
|
||||||
|
get_safety_config(car.CarParams.SafetyModel.hyundaiCanfd)]
|
||||||
|
else:
|
||||||
|
if candidate in LEGACY_SAFETY_MODE_CAR:
|
||||||
|
# these cars require a special panda safety mode due to missing counters and checksums in the messages
|
||||||
|
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hyundaiLegacy)]
|
||||||
|
else:
|
||||||
|
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hyundai, 0)]
|
||||||
|
|
||||||
# set appropriate safety param for gas signal
|
# set appropriate safety param for gas signal
|
||||||
if candidate in HYBRID_CAR:
|
if candidate in HYBRID_CAR:
|
||||||
ret.safetyConfigs[0].safetyParam = 2
|
ret.safetyConfigs[0].safetyParam = 2
|
||||||
elif candidate in EV_CAR:
|
elif candidate in EV_CAR:
|
||||||
ret.safetyConfigs[0].safetyParam = 1
|
ret.safetyConfigs[0].safetyParam = 1
|
||||||
|
|
||||||
|
if ret.openpilotLongitudinalControl:
|
||||||
|
ret.safetyConfigs[0].safetyParam |= Panda.FLAG_HYUNDAI_LONG
|
||||||
|
|
||||||
|
if candidate in CAMERA_SCC_CAR:
|
||||||
|
ret.safetyConfigs[0].safetyParam |= Panda.FLAG_HYUNDAI_CAMERA_SCC
|
||||||
|
|
||||||
ret.centerToFront = ret.wheelbase * 0.4
|
ret.centerToFront = ret.wheelbase * 0.4
|
||||||
|
|
||||||
|
@ -302,12 +312,6 @@ class CarInterface(CarInterfaceBase):
|
||||||
|
|
||||||
ret.enableBsm = 0x58b in fingerprint[0]
|
ret.enableBsm = 0x58b in fingerprint[0]
|
||||||
|
|
||||||
if ret.openpilotLongitudinalControl:
|
|
||||||
ret.safetyConfigs[0].safetyParam |= Panda.FLAG_HYUNDAI_LONG
|
|
||||||
|
|
||||||
if candidate in CAMERA_SCC_CAR:
|
|
||||||
ret.safetyConfigs[0].safetyParam |= Panda.FLAG_HYUNDAI_CAMERA_SCC
|
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -20,7 +20,7 @@ class CarControllerParams:
|
||||||
self.STEER_DRIVER_FACTOR = 1
|
self.STEER_DRIVER_FACTOR = 1
|
||||||
self.STEER_THRESHOLD = 150
|
self.STEER_THRESHOLD = 150
|
||||||
|
|
||||||
if CP.carFingerprint in HDA2_CAR:
|
if CP.carFingerprint in CANFD_CAR:
|
||||||
self.STEER_MAX = 270
|
self.STEER_MAX = 270
|
||||||
self.STEER_DRIVER_ALLOWANCE = 250
|
self.STEER_DRIVER_ALLOWANCE = 250
|
||||||
self.STEER_DRIVER_MULTIPLIER = 2
|
self.STEER_DRIVER_MULTIPLIER = 2
|
||||||
|
@ -1280,7 +1280,7 @@ FEATURES = {
|
||||||
"use_fca": {CAR.SONATA, CAR.SONATA_HYBRID, CAR.ELANTRA, CAR.ELANTRA_2021, CAR.ELANTRA_HEV_2021, CAR.ELANTRA_GT_I30, CAR.KIA_STINGER, CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.KONA_EV, CAR.KIA_FORTE, CAR.KIA_NIRO_EV, CAR.PALISADE, CAR.GENESIS_G70, CAR.GENESIS_G70_2020, CAR.KONA, CAR.SANTA_FE, CAR.KIA_SELTOS, CAR.KONA_HEV, CAR.SANTA_FE_2022, CAR.KIA_K5_2021, CAR.IONIQ_HEV_2022, CAR.SANTA_FE_HEV_2022, CAR.SANTA_FE_PHEV_2022, CAR.TUCSON, CAR.KONA_EV_2022},
|
"use_fca": {CAR.SONATA, CAR.SONATA_HYBRID, CAR.ELANTRA, CAR.ELANTRA_2021, CAR.ELANTRA_HEV_2021, CAR.ELANTRA_GT_I30, CAR.KIA_STINGER, CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.KONA_EV, CAR.KIA_FORTE, CAR.KIA_NIRO_EV, CAR.PALISADE, CAR.GENESIS_G70, CAR.GENESIS_G70_2020, CAR.KONA, CAR.SANTA_FE, CAR.KIA_SELTOS, CAR.KONA_HEV, CAR.SANTA_FE_2022, CAR.KIA_K5_2021, CAR.IONIQ_HEV_2022, CAR.SANTA_FE_HEV_2022, CAR.SANTA_FE_PHEV_2022, CAR.TUCSON, CAR.KONA_EV_2022},
|
||||||
}
|
}
|
||||||
|
|
||||||
HDA2_CAR = {CAR.KIA_EV6, }
|
CANFD_CAR = {CAR.KIA_EV6, }
|
||||||
|
|
||||||
# The camera does SCC on these cars, rather than the radar
|
# The camera does SCC on these cars, rather than the radar
|
||||||
CAMERA_SCC_CAR = {CAR.KONA_EV_2022, }
|
CAMERA_SCC_CAR = {CAR.KONA_EV_2022, }
|
||||||
|
|
Loading…
Reference in New Issue