diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index d9cc6ff..541ca40 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -59,6 +59,7 @@ class CarController: self.apply_steer_last = 0 self.car_fingerprint = CP.carFingerprint self.last_button_frame = 0 + self.last_resume_frame = 0 def update(self, CC, CS, now_nanos, sport_plus): actuators = CC.actuators @@ -241,9 +242,9 @@ class CarController: # Test this... # Also try create_acc_commands # This attempts to set the speed to - stopping = CC.actuators.longControlState == LongCtrlState.stopping - can_sends.append(hyundaicanfd.create_acc_control(self.packer, self.CAN, CC.enabled, self.accel_last, CC.actuators.accel, stopping, CC.cruiseControl.override, - 40, CS.personality_profile)) + # stopping = CC.actuators.longControlState == LongCtrlState.stopping + # can_sends.append(hyundaicanfd.create_acc_control(self.packer, self.CAN, CC.enabled, self.accel_last, CC.actuators.accel, stopping, CC.cruiseControl.override, + # 40, CS.personality_profile)) # cruise cancel if CC.cruiseControl.cancel: @@ -257,18 +258,21 @@ class CarController: # cruise standstill resume elif CC.cruiseControl.resume: - if self.CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS: - # oscar - test me - for _ in range(20): - # can_sends.append(hyundaicanfd.create_buttons(self.packer, self.CP, self.CAN, CS.buttons_counter+1, Buttons.CANCEL)) - can_sends.append(hyundaicanfd.create_buttons(self.packer, self.CP, self.CAN, CS.buttons_counter+1, Buttons.RES_ACCEL)) - self.last_button_frame = self.frame - else: - for _ in range(20): - can_sends.append(hyundaicanfd.create_buttons(self.packer, self.CP, self.CAN, CS.buttons_counter+1, Buttons.RES_ACCEL)) + if (self.frame - self.last_button_frame) * DT_CTRL > 4: + if self.CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS: + # for _ in range(20): + nothing = 0 + # Nothing for now --? + # oscar - test me + # can_sends.append(hyundaicanfd.create_buttons(self.packer, self.CP, self.CAN, CS.buttons_counter+1, Buttons.CANCEL)) + # can_sends.append(hyundaicanfd.create_buttons(self.packer, self.CP, self.CAN, CS.buttons_counter+1, Buttons.RES_ACCEL)) + else: + for _ in range(20): + can_sends.append(hyundaicanfd.create_buttons(self.packer, self.CP, self.CAN, CS.buttons_counter+1, Buttons.RES_ACCEL)) self.last_button_frame = self.frame + self.last_resume_frame = self.frame - elif set_speed_in_units is not None and not self.CP.openpilotLongitudinalControl and CS.cruiseState.available and not CS.out.gasPressed and CS.cruise_buttons == Buttons.NONE: + elif set_speed_in_units is not None and not self.CP.openpilotLongitudinalControl and CS.cruiseState.enabled and not CS.out.gasPressed and CS.cruise_buttons == Buttons.NONE: # 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