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 40b7b28f84.
pull/23636/head
Shane Smiskol 3 years ago committed by GitHub
parent cb6a68373b
commit 3c62d9da09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      opendbc
  2. 5
      selfdrive/car/toyota/carstate.py
  3. 12
      selfdrive/car/toyota/interface.py
  4. 3
      selfdrive/car/toyota/values.py

@ -1 +1 @@
Subproject commit e2acd0794c1e4c080231a9c2f85bbbc9dc423d34 Subproject commit d4a4614e0639d3fa79bd03377e6a61db48b57f17

@ -6,7 +6,7 @@ from opendbc.can.can_define import CANDefine
from selfdrive.car.interfaces import CarStateBase from selfdrive.car.interfaces import CarStateBase
from opendbc.can.parser import CANParser from opendbc.can.parser import CANParser
from selfdrive.config import Conversions as CV 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): class CarState(CarStateBase):
@ -14,6 +14,7 @@ class CarState(CarStateBase):
super().__init__(CP) super().__init__(CP)
can_define = CANDefine(DBC[CP.carFingerprint]["pt"]) can_define = CANDefine(DBC[CP.carFingerprint]["pt"])
self.shifter_values = can_define.dv["GEAR_PACKET"]["GEAR"] 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"] # On cars with cp.vl["STEER_TORQUE_SENSOR"]["STEER_ANGLE"]
# the signal is zeroed to where the steering angle is at start. # 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.rightBlinker = cp.vl["BLINKERS_STATE"]["TURN_SIGNALS"] == 2
ret.steeringTorque = cp.vl["STEER_TORQUE_SENSOR"]["STEER_TORQUE_DRIVER"] 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 # 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.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD
ret.steerWarning = cp.vl["EPS_STATUS"]["LKA_STATE"] not in (1, 5) ret.steerWarning = cp.vl["EPS_STATUS"]["LKA_STATE"] not in (1, 5)

@ -2,7 +2,7 @@
from cereal import car from cereal import car
from selfdrive.config import Conversions as CV 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.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 import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint, get_safety_config
from selfdrive.car.interfaces import CarInterfaceBase from selfdrive.car.interfaces import CarInterfaceBase
@ -20,17 +20,13 @@ class CarInterface(CarInterfaceBase):
ret.carName = "toyota" ret.carName = "toyota"
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.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.steerActuatorDelay = 0.12 # Default delay, Prius has larger delay
ret.steerLimitTimer = 0.4 ret.steerLimitTimer = 0.4
ret.stoppingControl = False # Toyota starts braking more when it thinks you want to stop 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: if candidate == CAR.PRIUS:
ret.safetyConfigs[0].safetyParam = 66 # see conversion factor for STEER_TORQUE_EPS in dbc file
stop_and_go = True stop_and_go = True
ret.wheelbase = 2.70 ret.wheelbase = 2.70
ret.steerRatio = 15.74 # unknown end-to-end spec ret.steerRatio = 15.74 # unknown end-to-end spec
@ -49,7 +45,6 @@ class CarInterface(CarInterfaceBase):
set_lat_tune(ret.lateralTuning, LatTunes.LQR_RAV4) set_lat_tune(ret.lateralTuning, LatTunes.LQR_RAV4)
elif candidate == CAR.COROLLA: elif candidate == CAR.COROLLA:
ret.safetyConfigs[0].safetyParam = 88
stop_and_go = False stop_and_go = False
ret.wheelbase = 2.70 ret.wheelbase = 2.70
ret.steerRatio = 18.27 ret.steerRatio = 18.27
@ -154,7 +149,6 @@ class CarInterface(CarInterfaceBase):
set_lat_tune(ret.lateralTuning, LatTunes.PID_J) set_lat_tune(ret.lateralTuning, LatTunes.PID_J)
elif candidate == CAR.LEXUS_IS: elif candidate == CAR.LEXUS_IS:
ret.safetyConfigs[0].safetyParam = 77
stop_and_go = False stop_and_go = False
ret.wheelbase = 2.79908 ret.wheelbase = 2.79908
ret.steerRatio = 13.3 ret.steerRatio = 13.3
@ -163,7 +157,6 @@ class CarInterface(CarInterfaceBase):
set_lat_tune(ret.lateralTuning, LatTunes.PID_L) set_lat_tune(ret.lateralTuning, LatTunes.PID_L)
elif candidate == CAR.LEXUS_RC: elif candidate == CAR.LEXUS_RC:
ret.safetyConfigs[0].safetyParam = 77
stop_and_go = False stop_and_go = False
ret.wheelbase = 2.73050 ret.wheelbase = 2.73050
ret.steerRatio = 13.3 ret.steerRatio = 13.3
@ -172,7 +165,6 @@ class CarInterface(CarInterfaceBase):
set_lat_tune(ret.lateralTuning, LatTunes.PID_L) set_lat_tune(ret.lateralTuning, LatTunes.PID_L)
elif candidate == CAR.LEXUS_CTH: elif candidate == CAR.LEXUS_CTH:
ret.safetyConfigs[0].safetyParam = 100
stop_and_go = True stop_and_go = True
ret.wheelbase = 2.60 ret.wheelbase = 2.60
ret.steerRatio = 18.6 ret.steerRatio = 18.6

@ -1,3 +1,4 @@
from collections import defaultdict
from enum import IntFlag from enum import IntFlag
from cereal import car from cereal import car
@ -1684,6 +1685,8 @@ DBC = {
CAR.ALPHARD_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), 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 # 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, TSS2_CAR = {CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2, CAR.LEXUS_ES_TSS2, CAR.LEXUS_ESH_TSS2, CAR.RAV4H_TSS2,

Loading…
Cancel
Save