From 29882b4519b00dbcd10f950dcf7c2986aae2fc1c Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 13 Aug 2024 22:08:48 -0700 Subject: [PATCH] Consistent spacing in car interfaces (#33293) * formatting * fix these * not these --- selfdrive/car/body/carstate.py | 1 + selfdrive/car/body/interface.py | 1 + selfdrive/car/gm/interface.py | 2 +- selfdrive/car/honda/interface.py | 2 +- selfdrive/car/hyundai/interface.py | 4 ++-- selfdrive/car/mazda/carstate.py | 1 + selfdrive/car/mazda/interface.py | 5 +++-- selfdrive/car/mock/interface.py | 1 + selfdrive/car/nissan/carstate.py | 1 + selfdrive/car/subaru/carstate.py | 3 +-- selfdrive/car/tesla/carstate.py | 1 + selfdrive/car/toyota/interface.py | 2 +- selfdrive/car/volkswagen/carstate.py | 3 ++- selfdrive/car/volkswagen/interface.py | 1 - 14 files changed, 17 insertions(+), 11 deletions(-) diff --git a/selfdrive/car/body/carstate.py b/selfdrive/car/body/carstate.py index f2a8d702f2..e0e710b116 100644 --- a/selfdrive/car/body/carstate.py +++ b/selfdrive/car/body/carstate.py @@ -3,6 +3,7 @@ from opendbc.can.parser import CANParser from openpilot.selfdrive.car.interfaces import CarStateBase from openpilot.selfdrive.car.body.values import DBC + class CarState(CarStateBase): def update(self, cp): ret = car.CarState.new_message() diff --git a/selfdrive/car/body/interface.py b/selfdrive/car/body/interface.py index f0b473cc1d..2c66074fd3 100644 --- a/selfdrive/car/body/interface.py +++ b/selfdrive/car/body/interface.py @@ -4,6 +4,7 @@ from openpilot.selfdrive.car import get_safety_config from openpilot.selfdrive.car.interfaces import CarInterfaceBase from openpilot.selfdrive.car.body.values import SPEED_FROM_RPM + class CarInterface(CarInterfaceBase): @staticmethod def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs): diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index 142301bf70..50c1cf510e 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -14,10 +14,10 @@ from openpilot.selfdrive.car.interfaces import CarInterfaceBase, TorqueFromLater ButtonType = car.CarState.ButtonEvent.Type TransmissionType = car.CarParams.TransmissionType NetworkLocation = car.CarParams.NetworkLocation + BUTTONS_DICT = {CruiseButtons.RES_ACCEL: ButtonType.accelCruise, CruiseButtons.DECEL_SET: ButtonType.decelCruise, CruiseButtons.MAIN: ButtonType.altButton3, CruiseButtons.CANCEL: ButtonType.cancel} - NON_LINEAR_TORQUE_PARAMS = { CAR.CHEVROLET_BOLT_EUV: [2.6531724862969748, 1.0, 0.1919764879840985, 0.009054123646805178], CAR.GMC_ACADIA: [4.78003305, 1.0, 0.3122, 0.05591772], diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py index 7ee40b3267..65e0a32414 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -10,9 +10,9 @@ from openpilot.selfdrive.car import create_button_events, get_safety_config from openpilot.selfdrive.car.interfaces import CarInterfaceBase from openpilot.selfdrive.car.disable_ecu import disable_ecu - ButtonType = car.CarState.ButtonEvent.Type TransmissionType = car.CarParams.TransmissionType + BUTTONS_DICT = {CruiseButtons.RES_ACCEL: ButtonType.accelCruise, CruiseButtons.DECEL_SET: ButtonType.decelCruise, CruiseButtons.MAIN: ButtonType.altButton3, CruiseButtons.CANCEL: ButtonType.cancel} SETTINGS_BUTTONS_DICT = {CruiseSettings.DISTANCE: ButtonType.gapAdjustCruise, CruiseSettings.LKAS: ButtonType.altButton1} diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index 739e9d6631..e94c1080e5 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -2,8 +2,8 @@ from cereal import car from panda import Panda from openpilot.selfdrive.car.hyundai.hyundaicanfd import CanBus from openpilot.selfdrive.car.hyundai.values import HyundaiFlags, CAR, DBC, CANFD_CAR, CAMERA_SCC_CAR, CANFD_RADAR_SCC_CAR, \ - CANFD_UNSUPPORTED_LONGITUDINAL_CAR, EV_CAR, HYBRID_CAR, LEGACY_SAFETY_MODE_CAR, \ - UNSUPPORTED_LONGITUDINAL_CAR, Buttons + CANFD_UNSUPPORTED_LONGITUDINAL_CAR, EV_CAR, HYBRID_CAR, LEGACY_SAFETY_MODE_CAR, \ + UNSUPPORTED_LONGITUDINAL_CAR, Buttons from openpilot.selfdrive.car.hyundai.radar_interface import RADAR_START_ADDR from openpilot.selfdrive.car import create_button_events, get_safety_config from openpilot.selfdrive.car.interfaces import CarInterfaceBase diff --git a/selfdrive/car/mazda/carstate.py b/selfdrive/car/mazda/carstate.py index 83aa09b66b..b07e75a225 100644 --- a/selfdrive/car/mazda/carstate.py +++ b/selfdrive/car/mazda/carstate.py @@ -5,6 +5,7 @@ from openpilot.selfdrive.car.conversions import Conversions as CV from openpilot.selfdrive.car.interfaces import CarStateBase from openpilot.selfdrive.car.mazda.values import DBC, LKAS_LIMITS, MazdaFlags + class CarState(CarStateBase): def __init__(self, CP): super().__init__(CP) diff --git a/selfdrive/car/mazda/interface.py b/selfdrive/car/mazda/interface.py index 984ca16698..07d40553d7 100755 --- a/selfdrive/car/mazda/interface.py +++ b/selfdrive/car/mazda/interface.py @@ -7,6 +7,7 @@ from openpilot.selfdrive.car.interfaces import CarInterfaceBase ButtonType = car.CarState.ButtonEvent.Type + class CarInterface(CarInterfaceBase): @staticmethod @@ -22,7 +23,7 @@ class CarInterface(CarInterfaceBase): CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) - if candidate not in (CAR.MAZDA_CX5_2022, ): + if candidate not in (CAR.MAZDA_CX5_2022,): ret.minSteerSpeed = LKAS_LIMITS.DISABLE_SPEED * CV.KPH_TO_MS ret.centerToFront = ret.wheelbase * 0.41 @@ -33,7 +34,7 @@ class CarInterface(CarInterfaceBase): def _update(self): ret = self.CS.update(self.cp, self.cp_cam) - # TODO: add button types for inc and dec + # TODO: add button types for inc and dec ret.buttonEvents = create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}) return ret diff --git a/selfdrive/car/mock/interface.py b/selfdrive/car/mock/interface.py index 06922888f7..cfd11d1cfb 100755 --- a/selfdrive/car/mock/interface.py +++ b/selfdrive/car/mock/interface.py @@ -3,6 +3,7 @@ from cereal import car import cereal.messaging as messaging from openpilot.selfdrive.car.interfaces import CarInterfaceBase + # mocked car interface for dashcam mode class CarInterface(CarInterfaceBase): def __init__(self, CP, CarController, CarState): diff --git a/selfdrive/car/nissan/carstate.py b/selfdrive/car/nissan/carstate.py index c38173c3e3..a9e9d9e9ba 100644 --- a/selfdrive/car/nissan/carstate.py +++ b/selfdrive/car/nissan/carstate.py @@ -9,6 +9,7 @@ from openpilot.selfdrive.car.nissan.values import CAR, DBC, CarControllerParams TORQUE_SAMPLES = 12 + class CarState(CarStateBase): def __init__(self, CP): super().__init__(CP) diff --git a/selfdrive/car/subaru/carstate.py b/selfdrive/car/subaru/carstate.py index 0501494fdd..7751785f0f 100644 --- a/selfdrive/car/subaru/carstate.py +++ b/selfdrive/car/subaru/carstate.py @@ -52,7 +52,7 @@ class CarState(CarStateBase): # continuous blinker signals for assisted lane change ret.leftBlinker, ret.rightBlinker = self.update_blinker_from_lamp(50, cp.vl["Dashlights"]["LEFT_BLINKER"], - cp.vl["Dashlights"]["RIGHT_BLINKER"]) + cp.vl["Dashlights"]["RIGHT_BLINKER"]) if self.CP.enableBsm: ret.leftBlindspot = (cp.vl["BSD_RCTA"]["L_ADJACENT"] == 1) or (cp.vl["BSD_RCTA"]["L_APPROACHING"] == 1) @@ -226,4 +226,3 @@ class CarState(CarStateBase): ] return CANParser(DBC[CP.carFingerprint]["pt"], messages, CanBus.alt) - diff --git a/selfdrive/car/tesla/carstate.py b/selfdrive/car/tesla/carstate.py index 5aa21cbc7c..262ac7add1 100644 --- a/selfdrive/car/tesla/carstate.py +++ b/selfdrive/car/tesla/carstate.py @@ -7,6 +7,7 @@ from openpilot.selfdrive.car.conversions import Conversions as CV from openpilot.selfdrive.car.tesla.values import CAR, DBC, CANBUS, GEAR_MAP, DOORS, BUTTONS from openpilot.selfdrive.car.interfaces import CarStateBase + class CarState(CarStateBase): def __init__(self, CP): super().__init__(CP) diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 3efaa142aa..0968fbf7f3 100644 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -2,7 +2,7 @@ from cereal import car from panda import Panda 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, \ - 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 create_button_events, get_safety_config from openpilot.selfdrive.car.disable_ecu import disable_ecu from openpilot.selfdrive.car.interfaces import CarInterfaceBase diff --git a/selfdrive/car/volkswagen/carstate.py b/selfdrive/car/volkswagen/carstate.py index c53639a7dd..3f3683329c 100644 --- a/selfdrive/car/volkswagen/carstate.py +++ b/selfdrive/car/volkswagen/carstate.py @@ -4,7 +4,7 @@ from opendbc.can.parser import CANParser from openpilot.selfdrive.car.interfaces import CarStateBase from openpilot.selfdrive.car.conversions import Conversions as CV from openpilot.selfdrive.car.volkswagen.values import DBC, CANBUS, NetworkLocation, TransmissionType, GearShifter, \ - CarControllerParams, VolkswagenFlags + CarControllerParams, VolkswagenFlags class CarState(CarStateBase): @@ -387,6 +387,7 @@ class MqbExtraSignals: ("SWA_01", 20), # From J1086 Lane Change Assist ] + class PqExtraSignals: # Additional signal and message lists for optional or bus-portable controllers fwd_radar_messages = [ diff --git a/selfdrive/car/volkswagen/interface.py b/selfdrive/car/volkswagen/interface.py index dd1a1fd1d8..3bd31a4d49 100644 --- a/selfdrive/car/volkswagen/interface.py +++ b/selfdrive/car/volkswagen/interface.py @@ -102,4 +102,3 @@ class CarInterface(CarInterfaceBase): ret = self.CS.update(self.cp, self.cp_cam, self.cp_ext, self.CP.transmissionType) return ret -