Skip to content
Open
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
18 changes: 9 additions & 9 deletions opendbc_repo/opendbc/car/hyundai/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def update(self, CC, CS, now_nanos):
self.steerDeltaDownLC = steerDeltaDownLC
else:
self.steerDeltaDownLC = self.steerDeltaDown

self.soft_hold_mode = 1 if params.get_int("AutoCruiseControl") > 1 else 2
self.hapticFeedbackWhenSpeedCamera = int(params.get_int("HapticFeedbackWhenSpeedCamera"))

Expand All @@ -184,7 +184,7 @@ def update(self, CC, CS, now_nanos):
else:
self.params.STEER_DELTA_UP = self.steerDeltaUp
self.params.STEER_DELTA_DOWN = self.steerDeltaDown

angle_control = self.CP.flags & HyundaiFlags.ANGLE_CONTROL

# steering torque
Expand All @@ -196,7 +196,7 @@ def update(self, CC, CS, now_nanos):
self.angle_limit_counter, self.max_angle_frames,
MAX_ANGLE_CONSECUTIVE_FRAMES)

#apply_angle = apply_std_steer_angle_limits(actuators.steeringAngleDeg, self.apply_angle_last, CS.out.vEgoRaw,
#apply_angle = apply_std_steer_angle_limits(actuators.steeringAngleDeg, self.apply_angle_last, CS.out.vEgoRaw,
# CS.out.steeringAngleDeg, CC.latActive, self.params.ANGLE_LIMITS)

MAX_LAT_ACCEL = 8.0
Expand All @@ -211,7 +211,7 @@ def update(self, CC, CS, now_nanos):
rate_deg_s = calc_rate_limit_by_lat_accel(self.apply_angle_last, CS.out.vEgoRaw, self.CP.wheelbase, MAX_LAT_ACCEL, MAX_RATE_LOW, MAX_RATE_HIGH)
if not same_dir:
rate_deg_s = min(rate_deg_s * UNWIND_SCALE, UNWIND_MAX)

rate_deg_per_tick = rate_deg_s * DT_CTRL
apply_angle = np.clip(actuators.steeringAngleDeg,
self.apply_angle_last - rate_deg_per_tick,
Expand Down Expand Up @@ -274,7 +274,7 @@ def update(self, CC, CS, now_nanos):

active_speed_decel = hud_control.activeCarrot == 3 and self.activeCarrot != 3 # 3: Speed Decel
self.activeCarrot = hud_control.activeCarrot
if active_speed_decel and self.speedCameraHapticEndFrame < 0: # 과속카메라 감속시작
if active_speed_decel and self.speedCameraHapticEndFrame < 0: # 과속카메라 감속시작
self.speedCameraHapticEndFrame = self.frame + (8.0 / DT_CTRL) #8초간 켜줌.
elif not active_speed_decel:
self.speedCameraHapticEndFrame = -1
Expand Down Expand Up @@ -331,7 +331,7 @@ def update(self, CC, CS, now_nanos):

# LFA and HDA icons
if self.frame % 5 == 0 and camera_scc:
can_sends.extend(hyundaicanfd.create_lfahda_cluster(self.packer, CS, self.CAN, CC.longActive, CC.latActive))
can_sends.extend(hyundaicanfd.create_lfahda_cluster(self.packer, CS, self.CAN, CC.longActive, CC.latActive, self.canfd_debug))

# blinkers
if hda2 and self.CP.flags & HyundaiFlags.ENABLE_BLINKERS:
Expand Down Expand Up @@ -365,7 +365,7 @@ def update(self, CC, CS, now_nanos):
can_sends.extend(hyundaicanfd.forward_button_message(self.packer, self.CAN, self.frame, CS, send_button, self.MainMode_ACC_trigger, self.LFA_trigger))
else:
can_sends.extend(self.create_button_messages(CC, CS, use_clu11=False))

else:
can_sends.append(hyundaican.create_lkas11(self.packer, self.frame, self.CP, apply_torque, apply_steer_req,
torque_fault, CS.lkas11, sys_warning, sys_state, CC.enabled,
Expand All @@ -384,7 +384,7 @@ def update(self, CC, CS, now_nanos):
#jerk = 3.0 if actuators.longControlState == LongCtrlState.pid else 1.0
use_fca = self.CP.flags & HyundaiFlags.USE_FCA.value
if camera_scc:

can_sends.extend(hyundaican.create_acc_commands_scc(self.packer, CC.enabled, accel, self.hyundai_jerk, int(self.frame / 2),
hud_control, set_speed_in_units, stopping,
CC.cruiseControl.override, casper_opt, CS, self.soft_hold_mode))
Expand Down Expand Up @@ -609,7 +609,7 @@ def check_carrot_cruise(self, CC, CS, hud_control, stopping, accel, a_target):
self.carrot_cruise_accel = max(carrot_cruise, self.carrot_cruise_accel - 1.0 * DT_CTRL) # 점진적으로 줄임.
if self.carrot_cruise == 0:
self.carrot_cruise_accel = CS.out.aEgo

def make_jerk(self, CP, CS, accel, actuators, hud_control):
if actuators.longControlState == LongCtrlState.stopping:
self.jerk = self.jerk_u_min / 2 - CS.out.aEgo
Expand Down
34 changes: 26 additions & 8 deletions opendbc_repo/opendbc/car/hyundai/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ def __init__(self, CP):
self.adrv_info_160 = None
self.adrv_info_162 = None
self.hda_info_4a3 = None
self.cluster_speed_limit = None
self.new_msg_4b4 = None

self.hda2_counter = 99
self.new_msg_4b9 = None

self.tcs_info_373 = None
self.mdps_info = {}
self.steer_touch_info = {}
Expand Down Expand Up @@ -123,7 +128,7 @@ def __init__(self, CP):

fingerprints_str = Params().get("FingerPrints", encoding='utf-8')
fingerprints = ast.literal_eval(fingerprints_str)
#print("fingerprints =", fingerprints)
# print("fingerprints =", fingerprints)
ecu_disabled = False
if self.CP.openpilotLongitudinalControl and not (self.CP.flags & HyundaiFlags.CANFD_CAMERA_SCC):
ecu_disabled = True
Expand All @@ -138,7 +143,7 @@ def __init__(self, CP):
self.SCC14 = True if 905 in fingerprints[bus_cruise] else False
self.FCA11 = False
self.FCA11_bus = Bus.cam

self.HAS_LFA_BUTTON = True if 913 in fingerprints[0] else False
self.CRUISE_BUTTON_ALT = True if 1007 in fingerprints[0] else False

Expand All @@ -151,8 +156,10 @@ def __init__(self, CP):
self.ADRV_0x1ea = True if 0x1ea in fingerprints[cam_bus] else False
self.ADRV_0x160 = True if 0x160 in fingerprints[cam_bus] else False
self.LFAHDA_CLUSTER = True if 480 in fingerprints[cam_bus] else False
self.CLUSTER_SPEED_LIMIT = True if 0x1fa in fingerprints[pt_bus] else False
self.HDA_INFO_4A3 = True if 0x4a3 in fingerprints[pt_bus] else False
self.NEW_MSG_4B4 = True if 0x4b4 in fingerprints[pt_bus] else False

self.GEAR = True if 69 in fingerprints[pt_bus] else False
self.GEAR_ALT = True if 64 in fingerprints[pt_bus] else False
self.CAM_0x362 = True if 0x362 in fingerprints[alt_bus] else False
Expand All @@ -163,7 +170,7 @@ def __init__(self, CP):

self.cp_bsm = None
self.time_zone = "UTC"

self.controls_ready_count = 0

def update(self, can_parsers) -> structs.CarState:
Expand Down Expand Up @@ -459,7 +466,7 @@ def update_canfd(self, can_parsers) -> structs.CarState:
ret.steeringAngleDeg = cp.vl["MDPS"]["STEERING_ANGLE_2"] * -1
else:
ret.steeringAngleDeg = cp.vl["STEERING_SENSORS"]["STEERING_ANGLE"] * -1

ret.steeringTorque = cp.vl["MDPS"]["STEERING_COL_TORQUE"]
ret.steeringTorqueEps = cp.vl["MDPS"]["STEERING_OUT_TORQUE"]
ret.steeringPressed = self.update_steering_pressed(abs(ret.steeringTorque) > self.params.STEER_THRESHOLD, 5)
Expand All @@ -470,7 +477,7 @@ def update_canfd(self, can_parsers) -> structs.CarState:
if self.STEER_TOUCH_2AF:
self.steer_touch_info = cp.vl["STEER_TOUCH_2AF"]

blinkers_info = cp.vl["BLINKERS"]
blinkers_info = cp.vl["BLINKERS"]
left_blinker_lamp = blinkers_info["LEFT_LAMP"] or blinkers_info["LEFT_LAMP_ALT"]
right_blinker_lamp = blinkers_info["RIGHT_LAMP"] or blinkers_info["RIGHT_LAMP_ALT"]
ret.leftBlinker, ret.rightBlinker = self.update_blinker_from_lamp(50, left_blinker_lamp, right_blinker_lamp)
Expand All @@ -497,7 +504,7 @@ def update_canfd(self, can_parsers) -> structs.CarState:
self.MainMode_ACC = cp_cam.vl["SCC_CONTROL"]["MainMode_ACC"] == 1
self.ACCMode = cp_cam.vl["SCC_CONTROL"]["ACCMode"]
self.LFA_ICON = cp_cam.vl["LFAHDA_CLUSTER"]["HDA_LFA_SymSta"]

if self.CP.openpilotLongitudinalControl:
# These are not used for engage/disengage since openpilot keeps track of state using the buttons
ret.cruiseState.enabled = cp.vl["TCS"]["ACC_REQ"] == 1
Expand All @@ -524,7 +531,7 @@ def update_canfd(self, can_parsers) -> structs.CarState:

if self.LFAHDA_CLUSTER:
self.lfahda_cluster_info = cp_cam.vl["LFAHDA_CLUSTER"]

corner = False
self.adrv_info_161 = cp_cam.vl["ADRV_0x161"] if self.CCNC_0x161 else None
self.adrv_info_162 = cp_cam.vl["CCNC_0x162"] if self.CCNC_0x162 else None
Expand All @@ -545,8 +552,10 @@ def update_canfd(self, can_parsers) -> structs.CarState:
ret.leftLatDist = self.adrv_info_1ea["LF_DETECT_LATERAL"]
ret.rightLatDist = self.adrv_info_1ea["RF_DETECT_LATERAL"]
self.adrv_info_160 = cp_cam.vl["ADRV_0x160"] if self.ADRV_0x160 else None
self.cluster_speed_limit = cp.vl["CLUSTER_SPEED_LIMIT"] if self.CLUSTER_SPEED_LIMIT else None

self.hda_info_4a3 = cp.vl["HDA_INFO_4A3"] if self.HDA_INFO_4A3 else None

if self.hda_info_4a3 is not None:
speedLimit = self.hda_info_4a3["SPEED_LIMIT"]
if not self.is_metric:
Expand All @@ -560,8 +569,17 @@ def update_canfd(self, can_parsers) -> structs.CarState:
self.time_zone = ZoneInfo(NUMERIC_TO_TZ.get(country_code, "UTC"))

self.new_msg_4b4 = cp.vl["NEW_MSG_4B4"] if self.NEW_MSG_4B4 else None

# self.new_msg_4b8 = cp.vl["NEW_MSG_4B8"] # if self.NEW_MSG_4B8 else None
# self.new_msg_4b9 = cp.vl["NEW_MSG_4B9"] # if self.NEW_MSG_4B9 else None
# self.new_msg_4ba = cp.vl["NEW_MSG_4BA"] # if self.NEW_MSG_4BA else None
# self.new_msg_4be = cp.vl["NEW_MSG_4BE"] # if self.NEW_MSG_4BE else None
# self.new_msg_4bf = cp.vl["NEW_MSG_4BF"] # if self.NEW_MSG_4BF else None
# self.new_msg_4c1 = cp.vl["NEW_MSG_4C1"] # if self.NEW_MSG_4C1 else None
# self.new_msg_4dc = cp.vl["NEW_MSG_4DC"] # if self.NEW_MSG_4DC else None

self.tcs_info_373 = cp.vl["TCS"]

ret.gearStep = cp.vl["GEAR"]["GEAR_STEP"] if self.GEAR else 0
if 1 <= ret.gearStep <= 8 and ret.gearShifter == GearShifter.unknown:
ret.gearShifter = GearShifter.drive
Expand Down
Loading
Loading