diff --git a/selfdrive/car/body/interface.py b/selfdrive/car/body/interface.py index 4d72d2f604..f797a7ecf8 100644 --- a/selfdrive/car/body/interface.py +++ b/selfdrive/car/body/interface.py @@ -37,6 +37,3 @@ class CarInterface(CarInterfaceBase): self.frame += 1 return ret - - def apply(self, c, now_nanos): - return self.CC.update(c, self.CS, now_nanos) diff --git a/selfdrive/car/chrysler/interface.py b/selfdrive/car/chrysler/interface.py index e799767f26..34298a1ead 100755 --- a/selfdrive/car/chrysler/interface.py +++ b/selfdrive/car/chrysler/interface.py @@ -94,6 +94,3 @@ class CarInterface(CarInterfaceBase): ret.events = events.to_msg() return ret - - def apply(self, c, now_nanos): - return self.CC.update(c, self.CS, now_nanos) diff --git a/selfdrive/car/ford/interface.py b/selfdrive/car/ford/interface.py index ed8b010491..7dca458083 100644 --- a/selfdrive/car/ford/interface.py +++ b/selfdrive/car/ford/interface.py @@ -71,6 +71,3 @@ class CarInterface(CarInterfaceBase): ret.events = events.to_msg() return ret - - def apply(self, c, now_nanos): - return self.CC.update(c, self.CS, now_nanos) diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index 1336e23c70..f470d6f468 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -237,6 +237,3 @@ class CarInterface(CarInterfaceBase): ret.events = events.to_msg() return ret - - def apply(self, c, now_nanos): - return self.CC.update(c, self.CS, now_nanos) diff --git a/selfdrive/car/honda/interface.py b/selfdrive/car/honda/interface.py index 812b60d479..9d76beb649 100755 --- a/selfdrive/car/honda/interface.py +++ b/selfdrive/car/honda/interface.py @@ -257,8 +257,3 @@ class CarInterface(CarInterfaceBase): ret.events = events.to_msg() return ret - - # pass in a car.CarControl - # to be called @ 100hz - def apply(self, c, now_nanos): - return self.CC.update(c, self.CS, now_nanos) diff --git a/selfdrive/car/hyundai/interface.py b/selfdrive/car/hyundai/interface.py index 69b5132806..7f8cf05907 100644 --- a/selfdrive/car/hyundai/interface.py +++ b/selfdrive/car/hyundai/interface.py @@ -175,6 +175,3 @@ class CarInterface(CarInterfaceBase): ret.events = events.to_msg() return ret - - def apply(self, c, now_nanos): - return self.CC.update(c, self.CS, now_nanos) diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index 97c9e84c96..be1518a25a 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -93,10 +93,13 @@ class CarInterfaceBase(ABC): self.cp_loopback = self.CS.get_loopback_can_parser(CP) self.can_parsers = [self.cp, self.cp_cam, self.cp_adas, self.cp_body, self.cp_loopback] - self.CC = None + self.CC: CarControllerBase = None if CarController is not None: self.CC = CarController(self.cp.dbc_name, CP, self.VM) + def apply(self, c: car.CarControl, now_nanos: int) -> tuple[car.CarControl.Actuators, list[tuple[int, int, bytes, int]]]: + return self.CC.update(c, self.CS, now_nanos) + @staticmethod def get_pid_accel_limits(CP, current_speed, cruise_speed): return ACCEL_MIN, ACCEL_MAX @@ -250,9 +253,6 @@ class CarInterfaceBase(ABC): return reader - @abstractmethod - def apply(self, c: car.CarControl, now_nanos: int) -> tuple[car.CarControl.Actuators, list[bytes]]: - pass def create_common_events(self, cs_out, extra_gears=None, pcm_enable=True, allow_enable=True, enable_buttons=(ButtonType.accelCruise, ButtonType.decelCruise)): @@ -460,7 +460,7 @@ SendCan = tuple[int, int, bytes, int] class CarControllerBase(ABC): @abstractmethod - def update(self, CC, CS, now_nanos) -> tuple[car.CarControl.Actuators, list[SendCan]]: + def update(self, CC: car.CarControl.Actuators, CS: car.CarState, now_nanos: int) -> tuple[car.CarControl.Actuators, list[SendCan]]: pass diff --git a/selfdrive/car/mazda/interface.py b/selfdrive/car/mazda/interface.py index 12d156fee8..a0fa73c021 100755 --- a/selfdrive/car/mazda/interface.py +++ b/selfdrive/car/mazda/interface.py @@ -48,6 +48,3 @@ class CarInterface(CarInterfaceBase): ret.events = events.to_msg() return ret - - def apply(self, c, now_nanos): - return self.CC.update(c, self.CS, now_nanos) diff --git a/selfdrive/car/mock/interface.py b/selfdrive/car/mock/interface.py index 2e4ac43033..6100717a74 100755 --- a/selfdrive/car/mock/interface.py +++ b/selfdrive/car/mock/interface.py @@ -29,7 +29,3 @@ class CarInterface(CarInterfaceBase): ret.vEgoRaw = self.sm[gps_sock].speed return ret - - def apply(self, c, now_nanos): - actuators = car.CarControl.Actuators.new_message() - return actuators, [] diff --git a/selfdrive/car/nissan/interface.py b/selfdrive/car/nissan/interface.py index 3e82b5192e..170f7de287 100644 --- a/selfdrive/car/nissan/interface.py +++ b/selfdrive/car/nissan/interface.py @@ -42,6 +42,3 @@ class CarInterface(CarInterfaceBase): ret.events = events.to_msg() return ret - - def apply(self, c, now_nanos): - return self.CC.update(c, self.CS, now_nanos) diff --git a/selfdrive/car/subaru/interface.py b/selfdrive/car/subaru/interface.py index 30e186bd09..340090ffa9 100644 --- a/selfdrive/car/subaru/interface.py +++ b/selfdrive/car/subaru/interface.py @@ -114,6 +114,3 @@ class CarInterface(CarInterfaceBase): def init(CP, logcan, sendcan): if CP.flags & SubaruFlags.DISABLE_EYESIGHT: disable_ecu(logcan, sendcan, bus=2, addr=GLOBAL_ES_ADDR, com_cont_req=b'\x28\x03\x01') - - def apply(self, c, now_nanos): - return self.CC.update(c, self.CS, now_nanos) diff --git a/selfdrive/car/tesla/interface.py b/selfdrive/car/tesla/interface.py index f989886738..9577578f5d 100755 --- a/selfdrive/car/tesla/interface.py +++ b/selfdrive/car/tesla/interface.py @@ -50,6 +50,3 @@ class CarInterface(CarInterfaceBase): ret.events = self.create_common_events(ret).to_msg() return ret - - def apply(self, c, now_nanos): - return self.CC.update(c, self.CS, now_nanos) diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 3683e7d049..424a885d53 100644 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -200,8 +200,3 @@ class CarInterface(CarInterfaceBase): ret.events = events.to_msg() return ret - - # pass in a car.CarControl - # to be called @ 100hz - def apply(self, c, now_nanos): - return self.CC.update(c, self.CS, now_nanos) diff --git a/selfdrive/car/volkswagen/carcontroller.py b/selfdrive/car/volkswagen/carcontroller.py index cfba43b4da..37a4ed36b8 100644 --- a/selfdrive/car/volkswagen/carcontroller.py +++ b/selfdrive/car/volkswagen/carcontroller.py @@ -18,6 +18,7 @@ class CarController(CarControllerBase): self.CCP = CarControllerParams(CP) self.CCS = pqcan if CP.flags & VolkswagenFlags.PQ else mqbcan self.packer_pt = CANPacker(dbc_name) + self.ext_bus = CANBUS.pt if CP.networkLocation == car.CarParams.NetworkLocation.fwdCamera else CANBUS.cam self.apply_steer_last = 0 self.gra_acc_counter_last = None @@ -26,7 +27,7 @@ class CarController(CarControllerBase): self.hca_frame_timer_running = 0 self.hca_frame_same_torque = 0 - def update(self, CC, CS, ext_bus, now_nanos): + def update(self, CC, CS, now_nanos): actuators = CC.actuators hud_control = CC.hudControl can_sends = [] @@ -108,7 +109,7 @@ class CarController(CarControllerBase): gra_send_ready = self.CP.pcmCruise and CS.gra_stock_values["COUNTER"] != self.gra_acc_counter_last if gra_send_ready and (CC.cruiseControl.cancel or CC.cruiseControl.resume): - can_sends.append(self.CCS.create_acc_buttons_control(self.packer_pt, ext_bus, CS.gra_stock_values, + can_sends.append(self.CCS.create_acc_buttons_control(self.packer_pt, self.ext_bus, CS.gra_stock_values, cancel=CC.cruiseControl.cancel, resume=CC.cruiseControl.resume)) new_actuators = actuators.copy() @@ -117,4 +118,4 @@ class CarController(CarControllerBase): self.gra_acc_counter_last = CS.gra_stock_values["COUNTER"] self.frame += 1 - return new_actuators, can_sends, self.eps_timer_soft_disable_alert + return new_actuators, can_sends diff --git a/selfdrive/car/volkswagen/interface.py b/selfdrive/car/volkswagen/interface.py index 43a8bcdddc..83a8cde9a8 100644 --- a/selfdrive/car/volkswagen/interface.py +++ b/selfdrive/car/volkswagen/interface.py @@ -19,8 +19,6 @@ class CarInterface(CarInterfaceBase): self.ext_bus = CANBUS.cam self.cp_ext = self.cp_cam - self.eps_timer_soft_disable_alert = False - @staticmethod def _get_params(ret, candidate: CAR, fingerprint, car_fw, experimental_long, docs): ret.carName = "volkswagen" @@ -126,13 +124,10 @@ class CarInterface(CarInterfaceBase): if c.enabled and ret.vEgo < self.CP.minEnableSpeed: events.add(EventName.speedTooLow) - if self.eps_timer_soft_disable_alert: + if self.CC.eps_timer_soft_disable_alert: events.add(EventName.steerTimeLimit) ret.events = events.to_msg() return ret - def apply(self, c, now_nanos): - new_actuators, can_sends, self.eps_timer_soft_disable_alert = self.CC.update(c, self.CS, self.ext_bus, now_nanos) - return new_actuators, can_sends