This commit is contained in:
Your Name
2024-06-09 16:08:19 -05:00
parent cb7eda64d9
commit a963ea0296
8 changed files with 63 additions and 233 deletions

View File

@@ -123,39 +123,40 @@ class CarController(CarControllerBase):
if self.frame % 5 == 0 and (not hda2 or hda2_long):
# CLEARPILOT TEST self.CS.lkas_enabled
# can_sends.append(hyundaicanfd.create_lfahda_cluster(self.packer, self.CAN, CC.enabled, CC.latActive))
params_memory = Params("/dev/shm/params")
lkas_icon = params_memory.get_bool("CPTLkasButtonAction") or CS.lkas_enabled
can_sends.append(hyundaicanfd.create_lfahda_cluster(self.packer, self.CAN, lkas_icon, lkas_icon))
# params_memory = Params("/dev/shm/params")
# lkas_icon = params_memory.get_bool("CPTLkasButtonAction") or CS.lkas_enabled
# lkas_icon = CS.experimentalMode
can_sends.append(hyundaicanfd.create_lfahda_cluster(self.packer, self.CAN, CS.experimentalMode, False))
# blinkers
if hda2 and self.CP.flags & HyundaiFlags.ENABLE_BLINKERS:
can_sends.extend(hyundaicanfd.create_spas_messages(self.packer, self.CAN, self.frame, CC.leftBlinker, CC.rightBlinker))
# params_memory = Params("/dev/shm/params")
if params_memory.get_bool("CPTLkasButtonAction"):
if self.frame % 10 == 0:
for _ in range(20):
can_sends.append(hyundaicanfd.create_buttons_alt(self.packer, self.CP, self.CAN, CS.buttons_counter+1, Buttons.SET_DECEL))
# if params_memory.get_bool("CPTLkasButtonAction"):
# if self.frame % 10 == 0:
# for _ in range(20):
# can_sends.append(hyundaicanfd.create_buttons_alt(self.packer, self.CP, self.CAN, CS.buttons_counter+1, Buttons.SET_DECEL))
# can_sends.extend(hyundaicanfd.create_adrv_messages(self.packer, self.CAN, self.frame))
# can_sends.append(hyundaicanfd.create_acc_set_speed(self.packer, self.CP, self.CAN, CS.cruise_info, 50))
# can_sends.append(hyundaicanfd.create_acc_cancel(self.packer, self.CP, self.CAN, CS.cruise_info))
# print("Debug cancel executed")
if self.CP.openpilotLongitudinalControl:
if self.CP.openpilotLongitudinalControl or CS.experimentalMode:
if hda2:
can_sends.extend(hyundaicanfd.create_adrv_messages(self.packer, self.CAN, self.frame))
if self.frame % 2 == 0:
can_sends.append(hyundaicanfd.create_acc_control(self.packer, self.CAN, CC.enabled, self.accel_last, accel, stopping, CC.cruiseControl.override,
set_speed_in_units, hud_control))
self.accel_last = accel
else:
# else:
# Clearpilot
# If cruise control was enabled or idle on start, force cancel
# if CS.fix_main_enabled_cancel_main:
# CS.fix_main_enabled_cancel_main = False
# CC.cruiseControl.cancel = True
# button presses
can_sends.extend(self.create_button_messages(CC, CS, use_clu11=False))
# 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_steer, apply_steer_req,
torque_fault, CS.lkas11, sys_warning, sys_state, CC.enabled,
@@ -211,7 +212,7 @@ class CarController(CarControllerBase):
self.last_button_frame = self.frame
else:
if (self.frame - self.last_button_frame) * DT_CTRL > 0.25:
params_memory = Params("/dev/shm/params")
# params_memory = Params("/dev/shm/params")
# if params_memory.get_bool("CPTLkasButtonAction"):
# params_memory.put_bool("CPTLkasButtonAction", False)
# CC.cruiseControl.cancel = True
@@ -221,9 +222,9 @@ class CarController(CarControllerBase):
if self.CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS:
# pass
# can_sends.append(hyundaicanfd.create_acc_cancel(self.packer, self.CP, self.CAN, CS.cruise_info))
for _ in range(20):
can_sends.append(hyundaicanfd.create_buttons_alt(self.packer, self.CP, self.CAN, CS.buttons_counter+1, Buttons.CANCEL))
print("Try Cancel Button Alt")
# for _ in range(20):
# can_sends.append(hyundaicanfd.create_buttons_alt(self.packer, self.CP, self.CAN, CS.buttons_counter+1, Buttons.CANCEL))
# print("Try Cancel Button Alt")
self.last_button_frame = self.frame
CS.lkas_trigger_result = 1
else: