From 257f3c1f48db650202d175c02ac40a2788855975 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Thu, 1 Aug 2024 06:28:20 -0400 Subject: [PATCH] enable for CAN-FD --- selfdrive/car/hyundai/carcontroller.py | 7 ++++--- selfdrive/car/hyundai/hyundaicanfd.py | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 4b7c4ac52b..b41ff020a0 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -221,6 +221,9 @@ class CarController(CarControllerBase): if self.CP.flags & HyundaiFlags.ENABLE_BLINKERS: can_sends.append([0x7b1, 0, b"\x02\x3E\x80\x00\x00\x00\x00\x00", self.CAN.ECAN]) + if self.CP.openpilotLongitudinalControl: + self.make_jerk(CS, accel, actuators) + # CAN-FD platforms if self.CP.carFingerprint in CANFD_CAR: hda2 = self.CP.flags & HyundaiFlags.CANFD_HDA2 @@ -249,7 +252,7 @@ class CarController(CarControllerBase): 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 and CS.out.cruiseState.enabled, self.accel_last, accel, stopping, CC.cruiseControl.override, - set_speed_in_units, hud_control)) + set_speed_in_units, hud_control, self.jerk_u, self.jerk_l)) self.accel_last = accel else: # button presses @@ -287,8 +290,6 @@ class CarController(CarControllerBase): self.last_button_frame = self.frame elif self.frame % 2 == 0: can_sends.extend([hyundaican.create_clu11(self.packer, (self.frame // 2) + 1, CS.clu11, self.cruise_button, self.CP)] * 25) - else: - self.make_jerk(CS, accel, actuators) # Parse lead distance from radarState and display the corresponding distance in the car's cluster if self.CP.openpilotLongitudinalControl and self.sm.updated['radarState'] and self.frame % 5 == 0: diff --git a/selfdrive/car/hyundai/hyundaicanfd.py b/selfdrive/car/hyundai/hyundaicanfd.py index 8225166bfa..cdb2d40c3c 100644 --- a/selfdrive/car/hyundai/hyundaicanfd.py +++ b/selfdrive/car/hyundai/hyundaicanfd.py @@ -121,7 +121,7 @@ def create_lfahda_cluster(packer, CAN, enabled, lat_active, lateral_paused, blin return packer.make_can_msg("LFAHDA_CLUSTER", CAN.ECAN, values) -def create_acc_control(packer, CAN, enabled, accel_last, accel, stopping, gas_override, set_speed, hud_control): +def create_acc_control(packer, CAN, enabled, accel_last, accel, stopping, gas_override, set_speed, hud_control, upper_jerk, lower_jerk): jerk = 5 jn = jerk / 50 if not enabled or gas_override: @@ -137,8 +137,8 @@ def create_acc_control(packer, CAN, enabled, accel_last, accel, stopping, gas_ov "aReqValue": a_val, "aReqRaw": a_raw, "VSetDis": set_speed, - "JerkLowerLimit": jerk if enabled else 1, - "JerkUpperLimit": 3.0, + "JerkLowerLimit": lower_jerk, + "JerkUpperLimit": upper_jerk, "ACC_ObjDist": 1, "ObjValid": 0,