Toyota: match dash set speed (#25649)

* toyota: match set speed from dash

* Use unit bit

* Use RSA2

* flip this

* Universal unit signal, set vEgoCluster

* remove this and bump opendbc

* detect if car interface sets cluster fields

* revert

* needs to be cp

* UI_SPEED is actually always in kph?

* forgot to actually convert it

* same in onroad

* try conv factor only for imperial

* Seems like UI_SPEED is not the UI speed at all

* the dash might floor it

* same openpilot behavior

* bump

* ego speed factor is dynamic across speeds, handle Lexus exceptions with
diff msg

* remove test, bump opendbc

* secret formula

* secret formula v2

* 1.03 is sufficient

* try short press

* bump opendbc

* surely this can be cleaned up

surely this can be cleaned up

* use filter

* redo factors

* try UI_SPEED again with a factor

try UI_SPEED again with a factor

* dash applies hysteresis to speed. this matches pretty well, but not exactly

* match only set speed

* clean up

* clean up

clean up

* Update ref_commit

* update refs

Co-authored-by: Willem Melching <willem.melching@gmail.com>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
pull/25647/head^2
Shane Smiskol 3 years ago committed by GitHub
parent 71d152bf51
commit 80533d6c03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      opendbc
  2. 14
      selfdrive/car/toyota/carstate.py
  3. 2
      selfdrive/test/process_replay/ref_commit

@ -1 +1 @@
Subproject commit 8c634615c5b6eb05ebdecc097bdc72f5403a3afa
Subproject commit 83d4cb9fd871a563f4a0af0102992c0b52c94310

@ -90,9 +90,17 @@ class CarState(CarStateBase):
if self.CP.carFingerprint in (CAR.LEXUS_IS, CAR.LEXUS_RC):
ret.cruiseState.available = cp.vl["DSU_CRUISE"]["MAIN_ON"] != 0
ret.cruiseState.speed = cp.vl["DSU_CRUISE"]["SET_SPEED"] * CV.KPH_TO_MS
cluster_set_speed = cp.vl["PCM_CRUISE_ALT"]["UI_SET_SPEED"]
else:
ret.cruiseState.available = cp.vl["PCM_CRUISE_2"]["MAIN_ON"] != 0
ret.cruiseState.speed = cp.vl["PCM_CRUISE_2"]["SET_SPEED"] * CV.KPH_TO_MS
cluster_set_speed = cp.vl["PCM_CRUISE_SM"]["UI_SET_SPEED"]
# UI_SET_SPEED is always non-zero when main is on, hide until first enable
if ret.cruiseState.speed != 0:
is_metric = cp.vl["BODY_CONTROL_STATE_2"]["UNITS"] in (1, 2)
conversion_factor = CV.KPH_TO_MS if is_metric else CV.MPH_TO_MS
ret.cruiseState.speedCluster = cluster_set_speed * conversion_factor
cp_acc = cp_cam if self.CP.carFingerprint in (TSS2_CAR - RADAR_ACC_CAR) else cp
@ -147,6 +155,7 @@ class CarState(CarStateBase):
("DOOR_OPEN_RR", "BODY_CONTROL_STATE"),
("SEATBELT_DRIVER_UNLATCHED", "BODY_CONTROL_STATE"),
("PARKING_BRAKE", "BODY_CONTROL_STATE"),
("UNITS", "BODY_CONTROL_STATE_2"),
("TC_DISABLED", "ESP_CONTROL"),
("BRAKE_HOLD_ACTIVE", "ESP_CONTROL"),
("STEER_FRACTION", "STEER_ANGLE_SENSOR"),
@ -154,6 +163,7 @@ class CarState(CarStateBase):
("CRUISE_ACTIVE", "PCM_CRUISE"),
("CRUISE_STATE", "PCM_CRUISE"),
("GAS_RELEASED", "PCM_CRUISE"),
("UI_SET_SPEED", "PCM_CRUISE_SM"),
("STEER_TORQUE_DRIVER", "STEER_TORQUE_SENSOR"),
("STEER_TORQUE_EPS", "STEER_TORQUE_SENSOR"),
("STEER_ANGLE", "STEER_TORQUE_SENSOR"),
@ -168,12 +178,14 @@ class CarState(CarStateBase):
("LIGHT_STALK", 1),
("BLINKERS_STATE", 0.15),
("BODY_CONTROL_STATE", 3),
("BODY_CONTROL_STATE_2", 2),
("ESP_CONTROL", 3),
("EPS_STATUS", 25),
("BRAKE_MODULE", 40),
("WHEEL_SPEEDS", 80),
("STEER_ANGLE_SENSOR", 80),
("PCM_CRUISE", 33),
("PCM_CRUISE_SM", 1),
("STEER_TORQUE_SENSOR", 50),
]
@ -187,7 +199,9 @@ class CarState(CarStateBase):
if CP.carFingerprint in (CAR.LEXUS_IS, CAR.LEXUS_RC):
signals.append(("MAIN_ON", "DSU_CRUISE"))
signals.append(("SET_SPEED", "DSU_CRUISE"))
signals.append(("UI_SET_SPEED", "PCM_CRUISE_ALT"))
checks.append(("DSU_CRUISE", 5))
checks.append(("PCM_CRUISE_ALT", 1))
else:
signals.append(("MAIN_ON", "PCM_CRUISE_2"))
signals.append(("SET_SPEED", "PCM_CRUISE_2"))

@ -1 +1 @@
e1c189b002a179763fa34f24e5d96f2b2d0c4c49
915309019fef256512ee30cf92cfae2e479dd04e
Loading…
Cancel
Save