From 8d971f06711a56fc2652b2e0eb78ef8fbe50154f Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 8 Feb 2024 14:50:44 -0600 Subject: [PATCH] wip --- selfdrive/car/hyundai/carcontroller.py | 45 +++++++++++++++----------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 8275b02..a70088c 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -154,25 +154,7 @@ class CarController: if not self.CP.openpilotLongitudinalControl: can_sends.extend(self.create_button_messages(CC, CS, use_clu11=True)) - # CSLC - if CC.enabled and CC.experimental_mode and CS.cruiseState.available and not CS.out.gasPressed and CS.cruise_buttons == Buttons.NONE: - # cslcSetSpeed = get_set_speed(self, hud_v_cruise) - cslcSetSpeed = set_speed_in_units - self.cruise_button = get_cslc_button(self, cslcSetSpeed, CS) - if self.cruise_button != Buttons.NONE: - # if self.CP.carFingerprint in LEGACY_SAFETY_MODE_CAR: - # send_freq = 1 - # # send resume at a max freq of 10Hz - # if (self.frame - self.last_button_frame) * DT_CTRL > 0.1 * send_freq: - # # send 25 messages at a time to increases the likelihood of cruise buttons being accepted - # can_sends.extend([hyundaican.create_clu11(self.packer, self.frame, CS.clu11, self.cruise_button, self.CP.carFingerprint)] * 25) - # if (self.frame - self.last_button_frame) * DT_CTRL >= 0.15 * send_freq: - # self.last_button_frame = self.frame - if self.frame % 2 == 0: - if self.CP.carFingerprint in CANFD_CAR: - can_sends.append(hyundaicanfd.create_buttons(self.packer, self.CP, self.CAN, ((self.frame // 2) + 1) % 0x10, self.cruise_button)) - else: - can_sends.extend([hyundaican.create_clu11(self.packer, (self.frame // 2) + 1, CS.clu11, self.cruise_button, self.CP.carFingerprint)] * 25) + if not self.CP.openpilotLongitudinalControl and CS.cruiseState.available and not CS.out.gasPressed and CS.cruise_buttons == Buttons.NONE if self.frame % 2 == 0 and self.CP.openpilotLongitudinalControl: # TODO: unclear if this is needed @@ -194,6 +176,30 @@ class CarController: if self.frame % 50 == 0 and self.CP.openpilotLongitudinalControl: can_sends.append(hyundaican.create_frt_radar_opt(self.packer)) + # CSLC + # if False and not self.CP.openpilotLongitudinalControl and CC.enabled and CC.experimental_mode and CS.cruiseState.available and not CS.out.gasPressed and CS.cruise_buttons == Buttons.NONE: + # # cslcSetSpeed = get_set_speed(self, hud_v_cruise) + # cslcSetSpeed = set_speed_in_units + # self.cruise_button = get_cslc_button(self, cslcSetSpeed, CS) + # if self.cruise_button != Buttons.NONE: + # # if self.CP.carFingerprint in LEGACY_SAFETY_MODE_CAR: + # # send_freq = 1 + # # # send resume at a max freq of 10Hz + # # if (self.frame - self.last_button_frame) * DT_CTRL > 0.1 * send_freq: + # # # send 25 messages at a time to increases the likelihood of cruise buttons being accepted + # # can_sends.extend([hyundaican.create_clu11(self.packer, self.frame, CS.clu11, self.cruise_button, self.CP.carFingerprint)] * 25) + # # if (self.frame - self.last_button_frame) * DT_CTRL >= 0.15 * send_freq: + # # self.last_button_frame = self.frame + # if self.frame % 2 == 0: + # if self.CP.carFingerprint in CANFD_CAR: + # can_sends.append(hyundaicanfd.create_buttons(self.packer, self.CP, self.CAN, ((self.frame // 2) + 1) % 0x10, self.cruise_button)) + # else: + # can_sends.extend([hyundaican.create_clu11(self.packer, (self.frame // 2) + 1, CS.clu11, self.cruise_button, self.CP.carFingerprint)] * 25) + + # Test + if CS.cruise_buttons == Buttons.NONE and CS.cruiseState.enabled: + can_sends.append(hyundaicanfd.create_buttons(self.packer, self.CP, self.CAN, ((self.frame // 2) + 1) % 0x10, Buttons.SET_DECEL)) + new_actuators = actuators.copy() new_actuators.steer = apply_steer / self.params.STEER_MAX new_actuators.steerOutputCan = apply_steer @@ -208,6 +214,7 @@ class CarController: if CS.oscar_lane_center_btn_pressed: CS.oscar_lane_center_btn_pressed= False CC.cruiseControl.resume = True + floog = floorp # Test me. # can_sends.append(hyundaicanfd.create_buttons(self.packer, self.CP, self.CAN, 1, Buttons.RES_ACCEL)) # if self.CP.openpilotLongitudinalControl: