diff --git a/selfdrive/car/body/carstate.py b/selfdrive/car/body/carstate.py index 6b6414ca9c..1d259df254 100644 --- a/selfdrive/car/body/carstate.py +++ b/selfdrive/car/body/carstate.py @@ -6,7 +6,7 @@ from openpilot.selfdrive.car.body.values import DBC STARTUP_TICKS = 100 class CarState(CarStateBase): - def update(self, cp): + def update(self, cp) -> structs.CarState: ret = structs.CarState() ret.wheelSpeeds.fl = cp.vl['MOTORS_DATA']['SPEED_L'] diff --git a/selfdrive/car/body/interface.py b/selfdrive/car/body/interface.py index 1d34e156a2..265dbe2f31 100644 --- a/selfdrive/car/body/interface.py +++ b/selfdrive/car/body/interface.py @@ -1,16 +1,18 @@ import math from cereal import car -from openpilot.selfdrive.car import DT_CTRL, get_safety_config -from openpilot.selfdrive.car.structs import CarParams +from openpilot.selfdrive.car import DT_CTRL, get_safety_config, structs from openpilot.selfdrive.car.interfaces import CarInterfaceBase +from openpilot.selfdrive.car.body.carstate import CarState from openpilot.selfdrive.car.body.values import SPEED_FROM_RPM class CarInterface(CarInterfaceBase): + CS: CarState + @staticmethod - def _get_params(ret: CarParams, candidate, fingerprint, car_fw, experimental_long, docs): + def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experimental_long, docs): ret.notCar = True ret.carName = "body" - ret.safetyConfigs = [get_safety_config(CarParams.SafetyModel.body)] + ret.safetyConfigs = [get_safety_config(structs.CarParams.SafetyModel.body)] ret.minSteerSpeed = -math.inf ret.maxLateralAccel = math.inf # TODO: set to a reasonable value @@ -21,11 +23,11 @@ class CarInterface(CarInterfaceBase): ret.radarUnavailable = True ret.openpilotLongitudinalControl = True - ret.steerControlType = CarParams.SteerControlType.angle + ret.steerControlType = structs.CarParams.SteerControlType.angle return ret - def _update(self, c): + def _update(self, c) -> structs.CarState: ret = self.CS.update(self.cp) # wait for everything to init first diff --git a/selfdrive/car/chrysler/carstate.py b/selfdrive/car/chrysler/carstate.py index e17d777c24..0d7d31f825 100644 --- a/selfdrive/car/chrysler/carstate.py +++ b/selfdrive/car/chrysler/carstate.py @@ -24,7 +24,7 @@ class CarState(CarStateBase): self.prev_distance_button = 0 self.distance_button = 0 - def update(self, cp, cp_cam): + def update(self, cp, cp_cam) -> structs.CarState: ret = structs.CarState() diff --git a/selfdrive/car/chrysler/interface.py b/selfdrive/car/chrysler/interface.py index 6644c117db..34b91ce3e8 100755 --- a/selfdrive/car/chrysler/interface.py +++ b/selfdrive/car/chrysler/interface.py @@ -2,6 +2,7 @@ from cereal import car from panda import Panda from openpilot.selfdrive.car import create_button_events, get_safety_config, structs +from openpilot.selfdrive.car.chrysler.carstate import CarState from openpilot.selfdrive.car.chrysler.values import CAR, RAM_HD, RAM_DT, RAM_CARS, ChryslerFlags from openpilot.selfdrive.car.interfaces import CarInterfaceBase @@ -9,6 +10,8 @@ ButtonType = structs.CarState.ButtonEvent.Type class CarInterface(CarInterfaceBase): + CS: CarState + @staticmethod def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experimental_long, docs): ret.carName = "chrysler" @@ -76,7 +79,7 @@ class CarInterface(CarInterfaceBase): return ret - def _update(self, c): + def _update(self, c) -> structs.CarState: ret = self.CS.update(self.cp, self.cp_cam) ret.buttonEvents = create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}) diff --git a/selfdrive/car/ford/carstate.py b/selfdrive/car/ford/carstate.py index 14c3174163..fd7f7ad594 100644 --- a/selfdrive/car/ford/carstate.py +++ b/selfdrive/car/ford/carstate.py @@ -22,7 +22,7 @@ class CarState(CarStateBase): self.prev_distance_button = 0 self.distance_button = 0 - def update(self, cp, cp_cam): + def update(self, cp, cp_cam) -> structs.CarState: ret = structs.CarState() # Occasionally on startup, the ABS module recalibrates the steering pinion offset, so we need to block engagement diff --git a/selfdrive/car/ford/interface.py b/selfdrive/car/ford/interface.py index 60309e19b7..192a12b9ec 100644 --- a/selfdrive/car/ford/interface.py +++ b/selfdrive/car/ford/interface.py @@ -2,6 +2,7 @@ from cereal import car from panda import Panda from openpilot.selfdrive.car import create_button_events, get_safety_config, structs from openpilot.selfdrive.car.conversions import Conversions as CV +from openpilot.selfdrive.car.ford.carstate import CarState from openpilot.selfdrive.car.ford.fordcan import CanBus from openpilot.selfdrive.car.ford.values import Ecu, FordFlags from openpilot.selfdrive.car.interfaces import CarInterfaceBase @@ -12,6 +13,8 @@ GearShifter = structs.CarState.GearShifter class CarInterface(CarInterfaceBase): + CS: CarState + @staticmethod def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experimental_long, docs): ret.carName = "ford" @@ -67,7 +70,7 @@ class CarInterface(CarInterfaceBase): ret.centerToFront = ret.wheelbase * 0.44 return ret - def _update(self, c): + def _update(self, c) -> structs.CarState: ret = self.CS.update(self.cp, self.cp_cam) ret.buttonEvents = create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}) diff --git a/selfdrive/car/gm/carstate.py b/selfdrive/car/gm/carstate.py index 03c681b5c4..a8b26a12cb 100644 --- a/selfdrive/car/gm/carstate.py +++ b/selfdrive/car/gm/carstate.py @@ -29,7 +29,7 @@ class CarState(CarStateBase): self.prev_distance_button = 0 self.distance_button = 0 - def update(self, pt_cp, cam_cp, loopback_cp): + def update(self, pt_cp, cam_cp, loopback_cp) -> structs.CarState: ret = structs.CarState() self.prev_cruise_buttons = self.cruise_buttons diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index 815f7992a1..68650dd874 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -8,6 +8,7 @@ from panda import Panda from openpilot.common.basedir import BASEDIR from openpilot.selfdrive.car import create_button_events, get_safety_config, get_friction, structs from openpilot.selfdrive.car.conversions import Conversions as CV +from openpilot.selfdrive.car.gm.carstate import CarState from openpilot.selfdrive.car.gm.radar_interface import RADAR_HEADER_MSG from openpilot.selfdrive.car.gm.values import CAR, CruiseButtons, CarControllerParams, EV_CAR, CAMERA_ACC_CAR, CanBus from openpilot.selfdrive.car.interfaces import CarInterfaceBase, TorqueFromLateralAccelCallbackType, FRICTION_THRESHOLD, LatControlInputs, NanoFFModel @@ -31,6 +32,8 @@ NEURAL_PARAMS_PATH = os.path.join(BASEDIR, 'selfdrive/car/torque_data/neural_ff_ class CarInterface(CarInterfaceBase): + CS: CarState + @staticmethod def get_pid_accel_limits(CP, current_speed, cruise_speed): return CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX @@ -202,7 +205,7 @@ class CarInterface(CarInterfaceBase): return ret # returns a car.CarState - def _update(self, c): + def _update(self, c) -> structs.CarState: ret = self.CS.update(self.cp, self.cp_cam, self.cp_loopback) # Don't add event if transitioning from INIT, unless it's to an actual button diff --git a/selfdrive/car/honda/carstate.py b/selfdrive/car/honda/carstate.py index 294742a841..67f380b8ce 100644 --- a/selfdrive/car/honda/carstate.py +++ b/selfdrive/car/honda/carstate.py @@ -104,7 +104,7 @@ class CarState(CarStateBase): # However, on cars without a digital speedometer this is not always present (HRV, FIT, CRV 2016, ILX and RDX) self.dash_speed_seen = False - def update(self, cp, cp_cam, cp_body): + def update(self, cp, cp_cam, cp_body) -> structs.CarState: ret = structs.CarState() # car params diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py index e43fc921c1..78e71be133 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -4,6 +4,7 @@ from panda import Panda from openpilot.selfdrive.car import create_button_events, get_safety_config, structs from openpilot.selfdrive.car.conversions import Conversions as CV from openpilot.selfdrive.car.helpers import interp +from openpilot.selfdrive.car.honda.carstate import CarState from openpilot.selfdrive.car.honda.hondacan import CanBus from openpilot.selfdrive.car.honda.values import CarControllerParams, CruiseButtons, CruiseSettings, HondaFlags, CAR, HONDA_BOSCH, \ HONDA_NIDEC_ALT_SCM_MESSAGES, HONDA_BOSCH_RADARLESS @@ -20,6 +21,8 @@ SETTINGS_BUTTONS_DICT = {CruiseSettings.DISTANCE: ButtonType.gapAdjustCruise, Cr class CarInterface(CarInterfaceBase): + CS: CarState + @staticmethod def get_pid_accel_limits(CP, current_speed, cruise_speed): if CP.carFingerprint in HONDA_BOSCH: @@ -222,7 +225,7 @@ class CarInterface(CarInterfaceBase): disable_ecu(can_recv, can_send, bus=1, addr=0x18DAB0F1, com_cont_req=b'\x28\x83\x03') # returns a car.CarState - def _update(self, c): + def _update(self, c) -> structs.CarState: ret = self.CS.update(self.cp, self.cp_cam, self.cp_body) ret.buttonEvents = [ diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index 66d23386d6..a5dc33f99b 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -52,7 +52,7 @@ class CarState(CarStateBase): self.params = CarControllerParams(CP) - def update(self, cp, cp_cam): + def update(self, cp, cp_cam) -> structs.CarState: if self.CP.carFingerprint in CANFD_CAR: return self.update_canfd(cp, cp_cam) @@ -168,7 +168,7 @@ class CarState(CarStateBase): return ret - def update_canfd(self, cp, cp_cam): + def update_canfd(self, cp, cp_cam) -> structs.CarState: ret = structs.CarState() self.is_metric = cp.vl["CRUISE_BUTTONS_ALT"]["DISTANCE_UNIT"] != 1 diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index 170dc6c100..65a82b1aac 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -1,6 +1,7 @@ from cereal import car from panda import Panda from openpilot.selfdrive.car import create_button_events, get_safety_config, structs +from openpilot.selfdrive.car.hyundai.carstate import CarState 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, \ @@ -18,6 +19,8 @@ BUTTONS_DICT = {Buttons.RES_ACCEL: ButtonType.accelCruise, Buttons.SET_DECEL: Bu class CarInterface(CarInterfaceBase): + CS: CarState + @staticmethod def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experimental_long, docs): ret.carName = "hyundai" @@ -150,7 +153,7 @@ class CarInterface(CarInterfaceBase): if CP.flags & HyundaiFlags.ENABLE_BLINKERS: disable_ecu(can_recv, can_send, bus=CanBus(CP).ECAN, addr=0x7B1, com_cont_req=b'\x28\x83\x01') - def _update(self, c): + def _update(self, c) -> structs.CarState: ret = self.CS.update(self.cp, self.cp_cam) if self.CS.CP.openpilotLongitudinalControl: diff --git a/selfdrive/car/mazda/carstate.py b/selfdrive/car/mazda/carstate.py index 0103fa9fb7..de8a870ba9 100644 --- a/selfdrive/car/mazda/carstate.py +++ b/selfdrive/car/mazda/carstate.py @@ -21,7 +21,7 @@ class CarState(CarStateBase): self.prev_distance_button = 0 self.distance_button = 0 - def update(self, cp, cp_cam): + def update(self, cp, cp_cam) -> structs.CarState: ret = structs.CarState() diff --git a/selfdrive/car/mazda/interface.py b/selfdrive/car/mazda/interface.py index 3a1b48d04c..8dcad2a2db 100755 --- a/selfdrive/car/mazda/interface.py +++ b/selfdrive/car/mazda/interface.py @@ -2,6 +2,7 @@ from cereal import car from openpilot.selfdrive.car import create_button_events, get_safety_config, structs from openpilot.selfdrive.car.conversions import Conversions as CV +from openpilot.selfdrive.car.mazda.carstate import CarState from openpilot.selfdrive.car.mazda.values import CAR, LKAS_LIMITS from openpilot.selfdrive.car.interfaces import CarInterfaceBase @@ -9,6 +10,7 @@ ButtonType = structs.CarState.ButtonEvent.Type EventName = car.CarEvent.EventName class CarInterface(CarInterfaceBase): + CS: CarState @staticmethod def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experimental_long, docs): @@ -31,7 +33,7 @@ class CarInterface(CarInterfaceBase): return ret # returns a car.CarState - def _update(self, c): + def _update(self, c) -> structs.CarState: ret = self.CS.update(self.cp, self.cp_cam) # TODO: add button types for inc and dec diff --git a/selfdrive/car/mock/interface.py b/selfdrive/car/mock/interface.py index 6d9a35991e..c9a8df9919 100755 --- a/selfdrive/car/mock/interface.py +++ b/selfdrive/car/mock/interface.py @@ -21,7 +21,7 @@ class CarInterface(CarInterfaceBase): ret.dashcamOnly = True return ret - def _update(self, c): + def _update(self, c) -> structs.CarState: self.sm.update(0) gps_sock = 'gpsLocationExternal' if self.sm.recv_frame['gpsLocationExternal'] > 1 else 'gpsLocation' diff --git a/selfdrive/car/nissan/carstate.py b/selfdrive/car/nissan/carstate.py index 4440559159..5d20f963e4 100644 --- a/selfdrive/car/nissan/carstate.py +++ b/selfdrive/car/nissan/carstate.py @@ -23,7 +23,7 @@ class CarState(CarStateBase): self.prev_distance_button = 0 self.distance_button = 0 - def update(self, cp, cp_adas, cp_cam): + def update(self, cp, cp_adas, cp_cam) -> structs.CarState: ret = structs.CarState() self.prev_distance_button = self.distance_button diff --git a/selfdrive/car/nissan/interface.py b/selfdrive/car/nissan/interface.py index 6c31110d14..3ba76fdd4f 100644 --- a/selfdrive/car/nissan/interface.py +++ b/selfdrive/car/nissan/interface.py @@ -2,12 +2,14 @@ from cereal import car from panda import Panda from openpilot.selfdrive.car import create_button_events, get_safety_config, structs from openpilot.selfdrive.car.interfaces import CarInterfaceBase +from openpilot.selfdrive.car.nissan.carstate import CarState from openpilot.selfdrive.car.nissan.values import CAR ButtonType = structs.CarState.ButtonEvent.Type class CarInterface(CarInterfaceBase): + CS: CarState @staticmethod def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experimental_long, docs): @@ -29,7 +31,7 @@ class CarInterface(CarInterfaceBase): return ret # returns a car.CarState - def _update(self, c): + def _update(self, c) -> structs.CarState: ret = self.CS.update(self.cp, self.cp_adas, self.cp_cam) ret.buttonEvents = create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}) diff --git a/selfdrive/car/subaru/carstate.py b/selfdrive/car/subaru/carstate.py index 4297f62fa8..f98d1c3999 100644 --- a/selfdrive/car/subaru/carstate.py +++ b/selfdrive/car/subaru/carstate.py @@ -16,7 +16,7 @@ class CarState(CarStateBase): self.angle_rate_calulator = CanSignalRateCalculator(50) - def update(self, cp, cp_cam, cp_body): + def update(self, cp, cp_cam, cp_body) -> structs.CarState: ret = structs.CarState() throttle_msg = cp.vl["Throttle"] if not (self.CP.flags & SubaruFlags.HYBRID) else cp_body.vl["Throttle_Hybrid"] diff --git a/selfdrive/car/subaru/interface.py b/selfdrive/car/subaru/interface.py index 717986438b..72410d2c80 100644 --- a/selfdrive/car/subaru/interface.py +++ b/selfdrive/car/subaru/interface.py @@ -1,15 +1,16 @@ from panda import Panda -from openpilot.selfdrive.car import get_safety_config -from openpilot.selfdrive.car.structs import CarParams +from openpilot.selfdrive.car import get_safety_config, structs from openpilot.selfdrive.car.disable_ecu import disable_ecu from openpilot.selfdrive.car.interfaces import CarInterfaceBase +from openpilot.selfdrive.car.subaru.carstate import CarState from openpilot.selfdrive.car.subaru.values import CAR, GLOBAL_ES_ADDR, SubaruFlags class CarInterface(CarInterfaceBase): + CS: CarState @staticmethod - def _get_params(ret: CarParams, candidate: CAR, fingerprint, car_fw, experimental_long, docs): + def _get_params(ret: structs.CarParams, candidate: CAR, fingerprint, car_fw, experimental_long, docs): ret.carName = "subaru" ret.radarUnavailable = True # for HYBRID CARS to be upstreamed, we need: @@ -25,10 +26,10 @@ class CarInterface(CarInterfaceBase): if ret.flags & SubaruFlags.PREGLOBAL: ret.enableBsm = 0x25c in fingerprint[0] - ret.safetyConfigs = [get_safety_config(CarParams.SafetyModel.subaruPreglobal)] + ret.safetyConfigs = [get_safety_config(structs.CarParams.SafetyModel.subaruPreglobal)] else: ret.enableBsm = 0x228 in fingerprint[0] - ret.safetyConfigs = [get_safety_config(CarParams.SafetyModel.subaru)] + ret.safetyConfigs = [get_safety_config(structs.CarParams.SafetyModel.subaru)] if ret.flags & SubaruFlags.GLOBAL_GEN2: ret.safetyConfigs[0].safetyParam |= Panda.FLAG_SUBARU_GEN2 @@ -36,7 +37,7 @@ class CarInterface(CarInterfaceBase): ret.steerActuatorDelay = 0.1 if ret.flags & SubaruFlags.LKAS_ANGLE: - ret.steerControlType = CarParams.SteerControlType.angle + ret.steerControlType = structs.CarParams.SteerControlType.angle else: CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) @@ -97,7 +98,7 @@ class CarInterface(CarInterfaceBase): return ret # returns a car.CarState - def _update(self, c): + def _update(self, c) -> structs.CarState: ret = self.CS.update(self.cp, self.cp_cam, self.cp_body) diff --git a/selfdrive/car/tesla/carstate.py b/selfdrive/car/tesla/carstate.py index a2d0a867aa..d1e88583ef 100644 --- a/selfdrive/car/tesla/carstate.py +++ b/selfdrive/car/tesla/carstate.py @@ -21,7 +21,7 @@ class CarState(CarStateBase): self.acc_state = 0 self.das_control_counters = deque(maxlen=32) - def update(self, cp, cp_cam): + def update(self, cp, cp_cam) -> structs.CarState: ret = structs.CarState() # Vehicle speed diff --git a/selfdrive/car/tesla/interface.py b/selfdrive/car/tesla/interface.py index 812836be02..b8a2b4960b 100755 --- a/selfdrive/car/tesla/interface.py +++ b/selfdrive/car/tesla/interface.py @@ -1,14 +1,16 @@ #!/usr/bin/env python3 from panda import Panda -from openpilot.selfdrive.car import get_safety_config -from openpilot.selfdrive.car.structs import CarParams +from openpilot.selfdrive.car import get_safety_config, structs +from openpilot.selfdrive.car.tesla.carstate import CarState from openpilot.selfdrive.car.tesla.values import CANBUS, CAR from openpilot.selfdrive.car.interfaces import CarInterfaceBase class CarInterface(CarInterfaceBase): + CS: CarState + @staticmethod - def _get_params(ret: CarParams, candidate, fingerprint, car_fw, experimental_long, docs): + def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experimental_long, docs): ret.carName = "tesla" # There is no safe way to do steer blending with user torque, @@ -16,7 +18,7 @@ class CarInterface(CarInterfaceBase): # how openpilot should be, hence dashcamOnly ret.dashcamOnly = True - ret.steerControlType = CarParams.SteerControlType.angle + ret.steerControlType = structs.CarParams.SteerControlType.angle ret.longitudinalActuatorDelay = 0.5 # s ret.radarTimeStep = (1.0 / 8) # 8Hz @@ -28,18 +30,18 @@ class CarInterface(CarInterfaceBase): ret.openpilotLongitudinalControl = True flags |= Panda.FLAG_TESLA_LONG_CONTROL ret.safetyConfigs = [ - get_safety_config(CarParams.SafetyModel.tesla, flags), - get_safety_config(CarParams.SafetyModel.tesla, flags | Panda.FLAG_TESLA_POWERTRAIN), + get_safety_config(structs.CarParams.SafetyModel.tesla, flags), + get_safety_config(structs.CarParams.SafetyModel.tesla, flags | Panda.FLAG_TESLA_POWERTRAIN), ] else: ret.openpilotLongitudinalControl = False - ret.safetyConfigs = [get_safety_config(CarParams.SafetyModel.tesla, flags)] + ret.safetyConfigs = [get_safety_config(structs.CarParams.SafetyModel.tesla, flags)] ret.steerLimitTimer = 1.0 ret.steerActuatorDelay = 0.25 return ret - def _update(self, c): + def _update(self, c) -> structs.CarState: ret = self.CS.update(self.cp, self.cp_cam) ret.events = self.create_common_events(ret).to_msg() diff --git a/selfdrive/car/volkswagen/carstate.py b/selfdrive/car/volkswagen/carstate.py index 42c6a57659..a37d2b5767 100644 --- a/selfdrive/car/volkswagen/carstate.py +++ b/selfdrive/car/volkswagen/carstate.py @@ -33,7 +33,7 @@ class CarState(CarStateBase): return button_events - def update(self, pt_cp, cam_cp, ext_cp, trans_type): + def update(self, pt_cp, cam_cp, ext_cp, trans_type) -> structs.CarState: if self.CP.flags & VolkswagenFlags.PQ: return self.update_pq(pt_cp, cam_cp, ext_cp, trans_type) @@ -156,7 +156,7 @@ class CarState(CarStateBase): self.frame += 1 return ret - def update_pq(self, pt_cp, cam_cp, ext_cp, trans_type): + def update_pq(self, pt_cp, cam_cp, ext_cp, trans_type) -> structs.CarState: ret = structs.CarState() # Update vehicle speed and acceleration from ABS wheel speeds. ret.wheelSpeeds = self.get_wheel_speeds( diff --git a/selfdrive/car/volkswagen/interface.py b/selfdrive/car/volkswagen/interface.py index 4dd3421cbd..ff1ed641a9 100644 --- a/selfdrive/car/volkswagen/interface.py +++ b/selfdrive/car/volkswagen/interface.py @@ -2,6 +2,8 @@ from cereal import car from panda import Panda from openpilot.selfdrive.car import get_safety_config, structs from openpilot.selfdrive.car.interfaces import CarInterfaceBase +from openpilot.selfdrive.car.volkswagen.carcontroller import CarController +from openpilot.selfdrive.car.volkswagen.carstate import CarState from openpilot.selfdrive.car.volkswagen.values import CAR, CANBUS, CarControllerParams, NetworkLocation, TransmissionType, GearShifter, VolkswagenFlags ButtonType = structs.CarState.ButtonEvent.Type @@ -9,6 +11,9 @@ EventName = car.CarEvent.EventName class CarInterface(CarInterfaceBase): + CS: CarState + CC: CarController + def __init__(self, CP, CarController, CarState): super().__init__(CP, CarController, CarState) @@ -101,7 +106,7 @@ class CarInterface(CarInterfaceBase): return ret # returns a car.CarState - def _update(self, c): + def _update(self, c) -> structs.CarState: ret = self.CS.update(self.cp, self.cp_cam, self.cp_ext, self.CP.transmissionType) events = self.create_common_events(ret, extra_gears=[GearShifter.eco, GearShifter.sport, GearShifter.manumatic],