mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-25 04:13:53 +08:00
Toyota: Move EPS torque factor to openpilot (#23635)
* use scaling * or we can do it this way * define default in one place * just specify * Revert "just specify" This reverts commit 40b7b28f8416497cd1337784d336c1dd4f5dd6e3.
This commit is contained in:
2
opendbc
2
opendbc
Submodule opendbc updated: e2acd0794c...d4a4614e06
@@ -6,7 +6,7 @@ from opendbc.can.can_define import CANDefine
|
||||
from selfdrive.car.interfaces import CarStateBase
|
||||
from opendbc.can.parser import CANParser
|
||||
from selfdrive.config import Conversions as CV
|
||||
from selfdrive.car.toyota.values import ToyotaFlags, CAR, DBC, STEER_THRESHOLD, NO_STOP_TIMER_CAR, TSS2_CAR
|
||||
from selfdrive.car.toyota.values import ToyotaFlags, CAR, DBC, STEER_THRESHOLD, NO_STOP_TIMER_CAR, TSS2_CAR, EPS_SCALE
|
||||
|
||||
|
||||
class CarState(CarStateBase):
|
||||
@@ -14,6 +14,7 @@ class CarState(CarStateBase):
|
||||
super().__init__(CP)
|
||||
can_define = CANDefine(DBC[CP.carFingerprint]["pt"])
|
||||
self.shifter_values = can_define.dv["GEAR_PACKET"]["GEAR"]
|
||||
self.eps_torque_scale = EPS_SCALE[CP.carFingerprint] / 100.
|
||||
|
||||
# On cars with cp.vl["STEER_TORQUE_SENSOR"]["STEER_ANGLE"]
|
||||
# the signal is zeroed to where the steering angle is at start.
|
||||
@@ -78,7 +79,7 @@ class CarState(CarStateBase):
|
||||
ret.rightBlinker = cp.vl["BLINKERS_STATE"]["TURN_SIGNALS"] == 2
|
||||
|
||||
ret.steeringTorque = cp.vl["STEER_TORQUE_SENSOR"]["STEER_TORQUE_DRIVER"]
|
||||
ret.steeringTorqueEps = cp.vl["STEER_TORQUE_SENSOR"]["STEER_TORQUE_EPS"]
|
||||
ret.steeringTorqueEps = cp.vl["STEER_TORQUE_SENSOR"]["STEER_TORQUE_EPS"] * self.eps_torque_scale
|
||||
# we could use the override bit from dbc, but it's triggered at too high torque values
|
||||
ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD
|
||||
ret.steerWarning = cp.vl["EPS_STATUS"]["LKA_STATE"] not in (1, 5)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
from cereal import car
|
||||
from selfdrive.config import Conversions as CV
|
||||
from selfdrive.car.toyota.tunes import LatTunes, LongTunes, set_long_tune, set_lat_tune
|
||||
from selfdrive.car.toyota.values import Ecu, CAR, ToyotaFlags, TSS2_CAR, NO_DSU_CAR, MIN_ACC_SPEED, CarControllerParams
|
||||
from selfdrive.car.toyota.values import Ecu, CAR, ToyotaFlags, TSS2_CAR, NO_DSU_CAR, MIN_ACC_SPEED, EPS_SCALE, CarControllerParams
|
||||
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint, get_safety_config
|
||||
from selfdrive.car.interfaces import CarInterfaceBase
|
||||
|
||||
@@ -20,17 +20,13 @@ class CarInterface(CarInterfaceBase):
|
||||
|
||||
ret.carName = "toyota"
|
||||
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.toyota)]
|
||||
ret.safetyConfigs[0].safetyParam = EPS_SCALE[candidate]
|
||||
|
||||
ret.steerActuatorDelay = 0.12 # Default delay, Prius has larger delay
|
||||
ret.steerLimitTimer = 0.4
|
||||
|
||||
ret.stoppingControl = False # Toyota starts braking more when it thinks you want to stop
|
||||
|
||||
# Most cars use this default safety param
|
||||
ret.safetyConfigs[0].safetyParam = 73
|
||||
|
||||
if candidate == CAR.PRIUS:
|
||||
ret.safetyConfigs[0].safetyParam = 66 # see conversion factor for STEER_TORQUE_EPS in dbc file
|
||||
stop_and_go = True
|
||||
ret.wheelbase = 2.70
|
||||
ret.steerRatio = 15.74 # unknown end-to-end spec
|
||||
@@ -49,7 +45,6 @@ class CarInterface(CarInterfaceBase):
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.LQR_RAV4)
|
||||
|
||||
elif candidate == CAR.COROLLA:
|
||||
ret.safetyConfigs[0].safetyParam = 88
|
||||
stop_and_go = False
|
||||
ret.wheelbase = 2.70
|
||||
ret.steerRatio = 18.27
|
||||
@@ -154,7 +149,6 @@ class CarInterface(CarInterfaceBase):
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_J)
|
||||
|
||||
elif candidate == CAR.LEXUS_IS:
|
||||
ret.safetyConfigs[0].safetyParam = 77
|
||||
stop_and_go = False
|
||||
ret.wheelbase = 2.79908
|
||||
ret.steerRatio = 13.3
|
||||
@@ -163,7 +157,6 @@ class CarInterface(CarInterfaceBase):
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_L)
|
||||
|
||||
elif candidate == CAR.LEXUS_RC:
|
||||
ret.safetyConfigs[0].safetyParam = 77
|
||||
stop_and_go = False
|
||||
ret.wheelbase = 2.73050
|
||||
ret.steerRatio = 13.3
|
||||
@@ -172,7 +165,6 @@ class CarInterface(CarInterfaceBase):
|
||||
set_lat_tune(ret.lateralTuning, LatTunes.PID_L)
|
||||
|
||||
elif candidate == CAR.LEXUS_CTH:
|
||||
ret.safetyConfigs[0].safetyParam = 100
|
||||
stop_and_go = True
|
||||
ret.wheelbase = 2.60
|
||||
ret.steerRatio = 18.6
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from collections import defaultdict
|
||||
from enum import IntFlag
|
||||
|
||||
from cereal import car
|
||||
@@ -1684,6 +1685,8 @@ DBC = {
|
||||
CAR.ALPHARD_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'),
|
||||
}
|
||||
|
||||
# These cars have non-standard EPS torque scale factors. All others are 73
|
||||
EPS_SCALE = defaultdict(lambda: 73, {CAR.PRIUS: 66, CAR.COROLLA: 88, CAR.LEXUS_IS: 77, CAR.LEXUS_RC: 77, CAR.LEXUS_CTH: 100})
|
||||
|
||||
# Toyota/Lexus Safety Sense 2.0 and 2.5
|
||||
TSS2_CAR = {CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2, CAR.LEXUS_ES_TSS2, CAR.LEXUS_ESH_TSS2, CAR.RAV4H_TSS2,
|
||||
|
||||
Reference in New Issue
Block a user