From f492184f8c83ec3c687d6f42d7ce4a29db554bfa Mon Sep 17 00:00:00 2001 From: Test User Date: Sat, 25 Apr 2026 13:58:16 -0500 Subject: [PATCH] add TI_Parameters class and update torque application in CarController Co-authored-by: Copilot --- .../opendbc/car/mazda/carcontroller.py | 4 ++-- opendbc_repo/opendbc/car/mazda/values.py | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/opendbc_repo/opendbc/car/mazda/carcontroller.py b/opendbc_repo/opendbc/car/mazda/carcontroller.py index 76bd8e428..c9bd1c31c 100644 --- a/opendbc_repo/opendbc/car/mazda/carcontroller.py +++ b/opendbc_repo/opendbc/car/mazda/carcontroller.py @@ -3,7 +3,7 @@ from opendbc.car import Bus, structs from opendbc.car.lateral import apply_driver_steer_torque_limits from opendbc.car.interfaces import CarControllerBase from opendbc.car.mazda import mazdacan -from opendbc.car.mazda.values import CarControllerParams, Buttons, MazdaSafetyFlags +from opendbc.car.mazda.values import CarControllerParams, Buttons, MazdaSafetyFlags, TI_Parameters from openpilot.common.realtime import ControlsTimer as Timer, DT_CTRL from openpilot.common.filter_simple import FirstOrderFilter from openpilot.common.params import Params @@ -40,7 +40,7 @@ class CarController(CarControllerBase): if CS.ti_lkas_allowed: ti_new_torque = int(round(CC.actuators.torque * self.ccp.STEER_MAX)) ti_apply_torque = apply_driver_steer_torque_limits(ti_new_torque, self.apply_torque_last, - CS.out.steeringTorque, self.ccp) + CS.out.steeringTorque, TI_Parameters) self.apply_torque_last = apply_torque self.ti_apply_torque_last = ti_apply_torque diff --git a/opendbc_repo/opendbc/car/mazda/values.py b/opendbc_repo/opendbc/car/mazda/values.py index 0e3a92f66..6e2f1391d 100644 --- a/opendbc_repo/opendbc/car/mazda/values.py +++ b/opendbc_repo/opendbc/car/mazda/values.py @@ -20,14 +20,6 @@ class CarControllerParams: self.STEER_DRIVER_MULTIPLIER = 40 # weight driver torque self.STEER_DRIVER_FACTOR = 1 # from dbc self.STEER_ERROR_MAX = 350 # max delta between torque cmd and torque motor - - self.TI_STEER_MAX = 600 # theoretical max_steer 2047 - self.TI_STEER_DELTA_UP = 6 # torque increase per refresh - self.TI_STEER_DELTA_DOWN = 15 # torque decrease per refresh - self.TI_STEER_DRIVER_ALLOWANCE = 15 # allowed driver torque before start limiting - self.TI_STEER_DRIVER_MULTIPLIER = 40 # weight driver torque - self.TI_STEER_DRIVER_FACTOR = 1 # from dbc - self.TI_STEER_ERROR_MAX = 350 # max delta between torque cmd and torque motor if CP.flags & (MazdaSafetyFlags.GEN2 | MazdaSafetyFlags.GEN3): self.STEER_MAX = 8000 self.STEER_DELTA_UP = 45 # torque increase per refresh @@ -37,6 +29,16 @@ class CarControllerParams: self.STEER_DRIVER_FACTOR = 1 # from dbc self.STEER_ERROR_MAX = 3500 # max delta between torque cmd and torque motor +class TI_Parameters: + STEER_STEP = 1 # 100 Hz + STEER_MAX = 600 # theoretical max_steer 2047 + STEER_DELTA_UP = 6 # torque increase per refresh + STEER_DELTA_DOWN = 15 # torque decrease per refresh + STEER_DRIVER_ALLOWANCE = 15 # allowed driver torque before start limiting + STEER_DRIVER_MULTIPLIER = 40 # weight driver torque + STEER_DRIVER_FACTOR = 1 # from dbc + STEER_ERROR_MAX = 350 # max delta between torque cmd and torque motor + class TI_STATE: DISCOVER = 0 OFF = 1