Common CI._update function (#33289)

* use CP

* no car control, consistent _update function signatures

* eh it's fine to name it whatever

* clean up

* oops

* !!

* now we can delete this!

* nobody does anymore
old-commit-hash: 7248b00086
pull/33314/head
Shane Smiskol 9 months ago committed by GitHub
parent fae517416e
commit 35a99d7fc6
  1. 2
      selfdrive/car/body/carstate.py
  2. 3
      selfdrive/car/body/interface.py
  3. 2
      selfdrive/car/chrysler/carstate.py
  4. 3
      selfdrive/car/chrysler/interface.py
  5. 2
      selfdrive/car/ford/carstate.py
  6. 3
      selfdrive/car/ford/interface.py
  7. 2
      selfdrive/car/gm/carstate.py
  8. 4
      selfdrive/car/gm/interface.py
  9. 2
      selfdrive/car/honda/carstate.py
  10. 4
      selfdrive/car/honda/interface.py
  11. 2
      selfdrive/car/hyundai/carstate.py
  12. 3
      selfdrive/car/hyundai/interface.py
  13. 5
      selfdrive/car/interfaces.py
  14. 2
      selfdrive/car/mazda/carstate.py
  15. 4
      selfdrive/car/mazda/interface.py
  16. 3
      selfdrive/car/mock/interface.py
  17. 2
      selfdrive/car/nissan/carstate.py
  18. 4
      selfdrive/car/nissan/interface.py
  19. 2
      selfdrive/car/subaru/carstate.py
  20. 4
      selfdrive/car/subaru/interface.py
  21. 2
      selfdrive/car/tesla/carstate.py
  22. 3
      selfdrive/car/tesla/interface.py
  23. 2
      selfdrive/car/toyota/carstate.py
  24. 4
      selfdrive/car/toyota/interface.py
  25. 19
      selfdrive/car/volkswagen/carstate.py
  26. 16
      selfdrive/car/volkswagen/interface.py

@ -5,7 +5,7 @@ from openpilot.selfdrive.car.body.values import DBC
class CarState(CarStateBase):
def update(self, cp):
def update(self, cp, *_):
ret = car.CarState.new_message()
ret.wheelSpeeds.fl = cp.vl['MOTORS_DATA']['SPEED_L']

@ -24,6 +24,3 @@ class CarInterface(CarInterfaceBase):
ret.steerControlType = car.CarParams.SteerControlType.angle
return ret
def _update(self):
return self.CS.update(self.cp)

@ -26,7 +26,7 @@ class CarState(CarStateBase):
self.distance_button = 0
def update(self, cp, cp_cam):
def update(self, cp, cp_cam, *_):
ret = car.CarState.new_message()

@ -73,6 +73,3 @@ class CarInterface(CarInterfaceBase):
ret.enableBsm = 720 in fingerprint[0]
return ret
def _update(self):
return self.CS.update(self.cp, self.cp_cam)

@ -21,7 +21,7 @@ class CarState(CarStateBase):
self.distance_button = 0
def update(self, cp, cp_cam):
def update(self, cp, cp_cam, *_):
ret = car.CarState.new_message()
# Occasionally on startup, the ABS module recalibrates the steering pinion offset, so we need to block engagement

@ -64,6 +64,3 @@ class CarInterface(CarInterfaceBase):
ret.autoResumeSng = ret.minEnableSpeed == -1.
ret.centerToFront = ret.wheelbase * 0.44
return ret
def _update(self):
return self.CS.update(self.cp, self.cp_cam)

@ -34,7 +34,7 @@ class CarState(CarStateBase):
self.distance_button = 0
def update(self, pt_cp, cam_cp, loopback_cp):
def update(self, pt_cp, cam_cp, _, __, loopback_cp):
ret = car.CarState.new_message()
prev_cruise_buttons = self.cruise_buttons

@ -193,7 +193,3 @@ class CarInterface(CarInterfaceBase):
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
return ret
# returns a car.CarState
def _update(self):
return self.CS.update(self.cp, self.cp_cam, self.cp_loopback)

@ -110,7 +110,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, __):
ret = car.CarState.new_message()
# car params

@ -214,7 +214,3 @@ class CarInterface(CarInterfaceBase):
def init(CP, can_recv, can_send):
if CP.carFingerprint in (HONDA_BOSCH - HONDA_BOSCH_RADARLESS) and CP.openpilotLongitudinalControl:
disable_ecu(can_recv, can_send, bus=1, addr=0x18DAB0F1, com_cont_req=b'\x28\x83\x03')
# returns a car.CarState
def _update(self):
return self.CS.update(self.cp, self.cp_cam, self.cp_body)

@ -58,7 +58,7 @@ class CarState(CarStateBase):
self.params = CarControllerParams(CP)
def update(self, cp, cp_cam):
def update(self, cp, cp_cam, *_):
if self.CP.carFingerprint in CANFD_CAR:
return self.update_canfd(cp, cp_cam)

@ -146,6 +146,3 @@ class CarInterface(CarInterfaceBase):
# for blinkers
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):
return self.CS.update(self.cp, self.cp_cam)

@ -217,9 +217,8 @@ class CarInterfaceBase(ABC):
tune.torque.latAccelOffset = 0.0
tune.torque.steeringAngleDeadzoneDeg = steering_angle_deadzone_deg
@abstractmethod
def _update(self) -> car.CarState:
pass
return self.CS.update(*self.can_parsers)
def update(self, can_packets: list[tuple[int, list[CanData]]]) -> car.CarState:
# parse can
@ -292,7 +291,7 @@ class CarStateBase(ABC):
self.v_ego_kf = KF1D(x0=x0, A=A, C=C[0], K=K)
@abstractmethod
def update(self, *args) -> car.CarState:
def update(self, cp, cp_cam, cp_adas, cp_body, cp_loopback) -> car.CarState:
pass
def update_speed_kf(self, v_ego_raw):

@ -24,7 +24,7 @@ class CarState(CarStateBase):
self.distance_button = 0
def update(self, cp, cp_cam):
def update(self, cp, cp_cam, *_):
ret = car.CarState.new_message()

@ -28,7 +28,3 @@ class CarInterface(CarInterfaceBase):
ret.centerToFront = ret.wheelbase * 0.41
return ret
# returns a car.CarState
def _update(self):
return self.CS.update(self.cp, self.cp_cam)

@ -14,6 +14,3 @@ class CarInterface(CarInterfaceBase):
ret.steerRatio = 13.
ret.dashcamOnly = True
return ret
def _update(self):
return self.CS.update()

@ -26,7 +26,7 @@ class CarState(CarStateBase):
self.distance_button = 0
def update(self, cp, cp_adas, cp_cam):
def update(self, cp, cp_cam, cp_adas, *_):
ret = car.CarState.new_message()
prev_distance_button = self.distance_button

@ -25,7 +25,3 @@ class CarInterface(CarInterfaceBase):
ret.safetyConfigs[0].safetyParam |= Panda.FLAG_NISSAN_ALT_EPS_BUS
return ret
# returns a car.CarState
def _update(self):
return self.CS.update(self.cp, self.cp_adas, self.cp_cam)

@ -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, __):
ret = car.CarState.new_message()
throttle_msg = cp.vl["Throttle"] if not (self.CP.flags & SubaruFlags.HYBRID) else cp_body.vl["Throttle_Hybrid"]

@ -96,10 +96,6 @@ class CarInterface(CarInterfaceBase):
return ret
# returns a car.CarState
def _update(self):
return self.CS.update(self.cp, self.cp_cam, self.cp_body)
@staticmethod
def init(CP, can_recv, can_send):
if CP.flags & SubaruFlags.DISABLE_EYESIGHT:

@ -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, *_):
ret = car.CarState.new_message()
# Vehicle speed

@ -38,6 +38,3 @@ class CarInterface(CarInterfaceBase):
ret.steerLimitTimer = 1.0
ret.steerActuatorDelay = 0.25
return ret
def _update(self):
return self.CS.update(self.cp, self.cp_cam)

@ -49,7 +49,7 @@ class CarState(CarStateBase):
self.acc_type = 1
self.lkas_hud = {}
def update(self, cp, cp_cam):
def update(self, cp, cp_cam, *_):
ret = car.CarState.new_message()
ret.doorOpen = any([cp.vl["BODY_CONTROL_STATE"]["DOOR_OPEN_FL"], cp.vl["BODY_CONTROL_STATE"]["DOOR_OPEN_FR"],

@ -141,7 +141,3 @@ class CarInterface(CarInterfaceBase):
if CP.flags & ToyotaFlags.DISABLE_RADAR.value:
communication_control = bytes([uds.SERVICE_TYPE.COMMUNICATION_CONTROL, uds.CONTROL_TYPE.ENABLE_RX_DISABLE_TX, uds.MESSAGE_TYPE.NORMAL])
disable_ecu(can_recv, can_send, bus=0, addr=0x750, sub_addr=0xf, com_cont_req=communication_control)
# returns a car.CarState
def _update(self):
return self.CS.update(self.cp, self.cp_cam)

@ -32,9 +32,12 @@ 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 = pt_cp if self.CP.networkLocation == NetworkLocation.fwdCamera else cam_cp
if self.CP.flags & VolkswagenFlags.PQ:
return self.update_pq(pt_cp, cam_cp, ext_cp, trans_type)
return self.update_pq(pt_cp, cam_cp, ext_cp)
ret = car.CarState.new_message()
# Update vehicle speed and acceleration from ABS wheel speeds.
@ -73,11 +76,11 @@ class CarState(CarStateBase):
ret.parkingBrake = bool(pt_cp.vl["Kombi_01"]["KBI_Handbremse"]) # FIXME: need to include an EPB check as well
# Update gear and/or clutch position data.
if trans_type == TransmissionType.automatic:
if self.CP.transmissionType == TransmissionType.automatic:
ret.gearShifter = self.parse_gear_shifter(self.CCP.shifter_values.get(pt_cp.vl["Getriebe_11"]["GE_Fahrstufe"], None))
elif trans_type == TransmissionType.direct:
elif self.CP.transmissionType == TransmissionType.direct:
ret.gearShifter = self.parse_gear_shifter(self.CCP.shifter_values.get(pt_cp.vl["EV_Gearshift"]["GearPosition"], None))
elif trans_type == TransmissionType.manual:
elif self.CP.transmissionType == TransmissionType.manual:
ret.clutchPressed = not pt_cp.vl["Motor_14"]["MO_Kuppl_schalter"]
if bool(pt_cp.vl["Gateway_72"]["BCM1_Rueckfahrlicht_Schalter"]):
ret.gearShifter = GearShifter.reverse
@ -155,7 +158,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):
ret = car.CarState.new_message()
# Update vehicle speed and acceleration from ABS wheel speeds.
ret.wheelSpeeds = self.get_wheel_speeds(
@ -187,9 +190,9 @@ class CarState(CarStateBase):
ret.parkingBrake = bool(pt_cp.vl["Kombi_1"]["Bremsinfo"])
# Update gear and/or clutch position data.
if trans_type == TransmissionType.automatic:
if self.CP.transmissionType == TransmissionType.automatic:
ret.gearShifter = self.parse_gear_shifter(self.CCP.shifter_values.get(pt_cp.vl["Getriebe_1"]["Waehlhebelposition__Getriebe_1_"], None))
elif trans_type == TransmissionType.manual:
elif self.CP.transmissionType == TransmissionType.manual:
ret.clutchPressed = not pt_cp.vl["Motor_1"]["Kupplungsschalter"]
reverse_light = bool(pt_cp.vl["Gate_Komf_1"]["GK1_Rueckfahr"])
if reverse_light:

@ -2,20 +2,10 @@ from cereal import car
from panda import Panda
from openpilot.selfdrive.car import get_safety_config
from openpilot.selfdrive.car.interfaces import CarInterfaceBase
from openpilot.selfdrive.car.volkswagen.values import CAR, CANBUS, NetworkLocation, TransmissionType, VolkswagenFlags
from openpilot.selfdrive.car.volkswagen.values import CAR, NetworkLocation, TransmissionType, VolkswagenFlags
class CarInterface(CarInterfaceBase):
def __init__(self, CP, CarController, CarState):
super().__init__(CP, CarController, CarState)
if CP.networkLocation == NetworkLocation.fwdCamera:
self.ext_bus = CANBUS.pt
self.cp_ext = self.cp
else:
self.ext_bus = CANBUS.cam
self.cp_ext = self.cp_cam
@staticmethod
def _get_params(ret, candidate: CAR, fingerprint, car_fw, experimental_long, docs):
ret.carName = "volkswagen"
@ -96,7 +86,3 @@ class CarInterface(CarInterfaceBase):
ret.autoResumeSng = ret.minEnableSpeed == -1
return ret
# returns a car.CarState
def _update(self):
return self.CS.update(self.cp, self.cp_cam, self.cp_ext, self.CP.transmissionType)

Loading…
Cancel
Save