Toyota TSS2: parse distance button (#31722)

* Enable the distance button to switch personalities for Toyota/Lexus

* Default to the "standard" personality for now

* only parsing first

* only parse

* no personality in card

* safe

* comment

---------

Co-authored-by: Shane Smiskol <shane@smiskol.com>
pull/31729/head
James 1 year ago committed by GitHub
parent 1644572be2
commit a2de0115b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      selfdrive/car/toyota/carstate.py
  2. 6
      selfdrive/car/toyota/interface.py

@ -40,6 +40,9 @@ class CarState(CarStateBase):
self.accurate_steer_angle_seen = False self.accurate_steer_angle_seen = False
self.angle_offset = FirstOrderFilter(None, 60.0, DT_CTRL, initialized=False) self.angle_offset = FirstOrderFilter(None, 60.0, DT_CTRL, initialized=False)
self.prev_distance_button = 0
self.distance_button = 0
self.low_speed_lockout = False self.low_speed_lockout = False
self.acc_type = 1 self.acc_type = 1
self.lkas_hud = {} self.lkas_hud = {}
@ -163,6 +166,11 @@ class CarState(CarStateBase):
if self.CP.carFingerprint != CAR.PRIUS_V: if self.CP.carFingerprint != CAR.PRIUS_V:
self.lkas_hud = copy.copy(cp_cam.vl["LKAS_HUD"]) self.lkas_hud = copy.copy(cp_cam.vl["LKAS_HUD"])
# distance button is wired to the ACC module (camera or radar)
if self.CP.carFingerprint in (TSS2_CAR - RADAR_ACC_CAR):
self.prev_distance_button = self.distance_button
self.distance_button = cp_acc.vl["ACC_CONTROL"]["DISTANCE"]
return ret return ret
@staticmethod @staticmethod

@ -3,10 +3,11 @@ from panda import Panda
from panda.python import uds from panda.python import uds
from openpilot.selfdrive.car.toyota.values import Ecu, CAR, DBC, ToyotaFlags, CarControllerParams, TSS2_CAR, RADAR_ACC_CAR, NO_DSU_CAR, \ from openpilot.selfdrive.car.toyota.values import Ecu, CAR, DBC, ToyotaFlags, CarControllerParams, TSS2_CAR, RADAR_ACC_CAR, NO_DSU_CAR, \
MIN_ACC_SPEED, EPS_SCALE, UNSUPPORTED_DSU_CAR, NO_STOP_TIMER_CAR, ANGLE_CONTROL_CAR MIN_ACC_SPEED, EPS_SCALE, UNSUPPORTED_DSU_CAR, NO_STOP_TIMER_CAR, ANGLE_CONTROL_CAR
from openpilot.selfdrive.car import get_safety_config from openpilot.selfdrive.car import create_button_events, get_safety_config
from openpilot.selfdrive.car.disable_ecu import disable_ecu from openpilot.selfdrive.car.disable_ecu import disable_ecu
from openpilot.selfdrive.car.interfaces import CarInterfaceBase from openpilot.selfdrive.car.interfaces import CarInterfaceBase
ButtonType = car.CarState.ButtonEvent.Type
EventName = car.CarEvent.EventName EventName = car.CarEvent.EventName
SteerControlType = car.CarParams.SteerControlType SteerControlType = car.CarParams.SteerControlType
@ -172,6 +173,9 @@ class CarInterface(CarInterfaceBase):
def _update(self, c): def _update(self, c):
ret = self.CS.update(self.cp, self.cp_cam) ret = self.CS.update(self.cp, self.cp_cam)
if self.CP.carFingerprint in (TSS2_CAR - RADAR_ACC_CAR):
ret.buttonEvents = create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise})
# events # events
events = self.create_common_events(ret) events = self.create_common_events(ret)

Loading…
Cancel
Save