From 2cab9543acf0a08e86a5f351a19e0cd032a09c4d Mon Sep 17 00:00:00 2001 From: MoreTorque <104254025+MoreTore@users.noreply.github.com> Date: Sat, 28 Feb 2026 08:50:32 -0600 Subject: [PATCH] fix ti command --- opendbc_repo/opendbc/car/mazda/carcontroller.py | 7 ++++--- opendbc_repo/opendbc/car/mazda/mazdacan.py | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/opendbc_repo/opendbc/car/mazda/carcontroller.py b/opendbc_repo/opendbc/car/mazda/carcontroller.py index 492e30888..4f64b3d6f 100644 --- a/opendbc_repo/opendbc/car/mazda/carcontroller.py +++ b/opendbc_repo/opendbc/car/mazda/carcontroller.py @@ -39,7 +39,7 @@ class CarController(CarControllerBase): if self.CP.flags & MazdaSafetyFlags.TORQUE_INTERCEPTOR: if CS.ti_lkas_allowed: ti_new_torque = int(round(CC.actuators.steer * self.ccp.STEER_MAX)) - ti_apply_torque = apply_driver_steer_torque_limits(ti_new_torque, self.ti_apply_steer_last, + ti_apply_torque = apply_driver_steer_torque_limits(ti_new_torque, self.apply_torque_last, CS.out.steeringTorque, self.ccp) self.apply_torque_last = apply_torque @@ -117,8 +117,9 @@ class CarController(CarControllerBase): # send steering command - can_sends.extend(mazdacan.create_steering_control(self.packer, self.CP, - self.frame, apply_torque, CS.cam_lkas)) + can_sends.extend(mazdacan.create_steering_control( + self.packer, self.CP, self.frame, apply_torque, CS.cam_lkas, + ti_apply_torque if CP.flags & MazdaSafetyFlags.TORQUE_INTERCEPTOR else None)) new_actuators = CC.actuators.as_builder() new_actuators.torque = apply_torque / self.ccp.STEER_MAX diff --git a/opendbc_repo/opendbc/car/mazda/mazdacan.py b/opendbc_repo/opendbc/car/mazda/mazdacan.py index 782434d58..9c4dfba69 100644 --- a/opendbc_repo/opendbc/car/mazda/mazdacan.py +++ b/opendbc_repo/opendbc/car/mazda/mazdacan.py @@ -1,7 +1,7 @@ from opendbc.car.mazda.values import Buttons, MazdaSafetyFlags from numpy import clip -def create_steering_control(packer, CP, frame, apply_torque, lkas): +def create_steering_control(packer, CP, frame, apply_torque, lkas, ti_apply_torque = None): msgs = [] if CP.flags & MazdaSafetyFlags.GEN1: if not CP.flags & MazdaSafetyFlags.NO_FSC: @@ -60,10 +60,10 @@ def create_steering_control(packer, CP, frame, apply_torque, lkas): } msgs.append(packer.make_can_msg("CAM_LKAS", 0, values)) - if CP.flags & MazdaSafetyFlags.TORQUE_INTERCEPTOR: + if ti_apply_torque is not None: values = { - "LKAS_REQUEST" : apply_torque, - "CHKSUM" : apply_torque, + "LKAS_REQUEST" : ti_apply_torque, + "CHKSUM" : ti_apply_torque, "KEY" : 3294744160 } msgs.append(packer.make_can_msg("CAM_LKAS2", 1, values))