diff --git a/opendbc_repo b/opendbc_repo index 39773a987e..4aa7ca9722 160000 --- a/opendbc_repo +++ b/opendbc_repo @@ -1 +1 @@ -Subproject commit 39773a987eaefd680c6befa390d7898945daf2e7 +Subproject commit 4aa7ca972290af6c6bbd314d1975eab46a888b6f diff --git a/selfdrive/car/car_specific.py b/selfdrive/car/car_specific.py index 307132e780..90e4a6986a 100644 --- a/selfdrive/car/car_specific.py +++ b/selfdrive/car/car_specific.py @@ -1,5 +1,6 @@ from cereal import car, log from opendbc.car import DT_CTRL, structs +from opendbc.car.car_helpers import interfaces from opendbc.car.interfaces import MAX_CTRL_SPEED from openpilot.selfdrive.selfdrived.events import Events @@ -10,18 +11,6 @@ EventName = log.OnroadEvent.EventName NetworkLocation = structs.CarParams.NetworkLocation -BRAND_EXTRA_GEARS = { - 'ford': [GearShifter.low, GearShifter.manumatic], - 'nissan': [GearShifter.brake], - 'chrysler': [GearShifter.low], - 'honda': [GearShifter.sport], - 'toyota': [GearShifter.sport], - 'gm': [GearShifter.sport, GearShifter.low, GearShifter.eco, GearShifter.manumatic], - 'volkswagen': [GearShifter.eco, GearShifter.sport, GearShifter.manumatic], - 'hyundai': [GearShifter.sport, GearShifter.manumatic] -} - - class CarSpecificEvents: def __init__(self, CP: structs.CarParams): self.CP = CP @@ -32,7 +21,7 @@ class CarSpecificEvents: self.silent_steer_warning = True def update(self, CS: car.CarState, CS_prev: car.CarState, CC: car.CarControl): - extra_gears = BRAND_EXTRA_GEARS.get(self.CP.brand, None) + extra_gears = interfaces[self.CP.carFingerprint].DRIVABLE_GEARS if self.CP.brand in ('body', 'mock'): events = Events() @@ -118,7 +107,7 @@ class CarSpecificEvents: return events - def create_common_events(self, CS: structs.CarState, CS_prev: car.CarState, extra_gears: list | None = None, pcm_enable=True, + def create_common_events(self, CS: structs.CarState, CS_prev: car.CarState, extra_gears: tuple = (), pcm_enable=True, allow_button_cancel=True): events = Events() @@ -126,8 +115,7 @@ class CarSpecificEvents: events.add(EventName.doorOpen) if CS.seatbeltUnlatched: events.add(EventName.seatbeltNotLatched) - if CS.gearShifter != GearShifter.drive and (extra_gears is None or - CS.gearShifter not in extra_gears): + if CS.gearShifter != GearShifter.drive and CS.gearShifter not in extra_gears: events.add(EventName.wrongGear) if CS.gearShifter == GearShifter.reverse: events.add(EventName.reverseGear)