From 31f395f440b66b89e6537e03d8283387c70e20f2 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 18 May 2023 00:27:51 -0700 Subject: [PATCH] just calculate in function --- selfdrive/car/ford/carcontroller.py | 4 +--- selfdrive/car/ford/fordcan.py | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/selfdrive/car/ford/carcontroller.py b/selfdrive/car/ford/carcontroller.py index 38a6c829f1..a369221569 100644 --- a/selfdrive/car/ford/carcontroller.py +++ b/selfdrive/car/ford/carcontroller.py @@ -85,16 +85,14 @@ class CarController: if CC.longActive: accel = clip(actuators.accel, CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX) gas = accel - decel = accel < 0.0 if accel < -0.5: gas = -5.0 else: accel = 0.0 # -0.0008 m/s^2 on CAN gas = -5.0 - decel = False stopping = CC.actuators.longControlState == LongCtrlState.stopping - can_sends.append(create_acc_msg(self.packer, CC.longActive, gas, accel, decel, stopping)) + can_sends.append(create_acc_msg(self.packer, CC.longActive, gas, accel, stopping)) ### ui ### send_ui = (self.main_on_last != main_on) or (self.lkas_enabled_last != CC.latActive) or (self.steer_alert_last != steer_alert) diff --git a/selfdrive/car/ford/fordcan.py b/selfdrive/car/ford/fordcan.py index daf880aa82..9095e7d0d1 100644 --- a/selfdrive/car/ford/fordcan.py +++ b/selfdrive/car/ford/fordcan.py @@ -101,7 +101,7 @@ def create_lat_ctl2_msg(packer, mode: int, path_offset: float, path_angle: float return packer.make_can_msg("LateralMotionControl2", CANBUS.main, values) -def create_acc_msg(packer, long_active: bool, gas: float, accel: float, decel: bool, stopping: bool): +def create_acc_msg(packer, long_active: bool, gas: float, accel: float, stopping: bool): """ Creates a CAN message for the Ford ACC Command. @@ -111,6 +111,7 @@ def create_acc_msg(packer, long_active: bool, gas: float, accel: float, decel: b Frequency is 50Hz. """ + decel = 1 if accel < 0 and long_active else 0 values = { "AccBrkTot_A_Rq": accel, # Brake total accel request: [-20|11.9449] m/s^2 "Cmbb_B_Enbl": 1 if long_active else 0, # Enabled: 0=No, 1=Yes