add TI_Parameters class and update torque application in CarController

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Test User
2026-04-25 13:58:16 -05:00
committed by Comma Device
parent 6f526145fd
commit f492184f8c
2 changed files with 12 additions and 10 deletions
@@ -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
+10 -8
View File
@@ -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