proper toyota+others CS typing!

pull/33208/head
Shane Smiskol 1 year ago
parent 777f62975b
commit 12d89d0036
  1. 2
      selfdrive/car/__init__.py
  2. 2
      selfdrive/car/ford/carstate.py
  3. 9
      selfdrive/car/interfaces.py
  4. 3
      selfdrive/car/toyota/carstate.py
  5. 6
      selfdrive/car/toyota/interface.py

@ -9,8 +9,8 @@ import capnp
from cereal import car from cereal import car
from panda.python.uds import SERVICE_TYPE from panda.python.uds import SERVICE_TYPE
from openpilot.selfdrive.car.can_definitions import CanData
from openpilot.selfdrive.car import structs from openpilot.selfdrive.car import structs
from openpilot.selfdrive.car.can_definitions import CanData
from openpilot.selfdrive.car.docs_definitions import CarDocs from openpilot.selfdrive.car.docs_definitions import CarDocs
from openpilot.selfdrive.car.helpers import clip, interp from openpilot.selfdrive.car.helpers import clip, interp

@ -1,7 +1,7 @@
from opendbc.can.can_define import CANDefine from opendbc.can.can_define import CANDefine
from opendbc.can.parser import CANParser from opendbc.can.parser import CANParser
from openpilot.selfdrive.car.conversions import Conversions as CV
from openpilot.selfdrive.car import structs from openpilot.selfdrive.car import structs
from openpilot.selfdrive.car.conversions import Conversions as CV
from openpilot.selfdrive.car.ford.fordcan import CanBus from openpilot.selfdrive.car.ford.fordcan import CanBus
from openpilot.selfdrive.car.ford.values import DBC, CarControllerParams, FordFlags from openpilot.selfdrive.car.ford.values import DBC, CarControllerParams, FordFlags
from openpilot.selfdrive.car.interfaces import CarStateBase from openpilot.selfdrive.car.interfaces import CarStateBase

@ -101,7 +101,7 @@ class CarInterfaceBase(ABC):
# TODO: this # TODO: this
# self.CS: CarStateBase = CarState(CP) # self.CS: CarStateBase = CarState(CP)
self.CS = CarState(CP) self.CS: CarStateBase = CarState(CP)
self.cp = self.CS.get_can_parser(CP) self.cp = self.CS.get_can_parser(CP)
self.cp_cam = self.CS.get_cam_can_parser(CP) self.cp_cam = self.CS.get_cam_can_parser(CP)
self.cp_adas = self.CS.get_adas_can_parser(CP) self.cp_adas = self.CS.get_adas_can_parser(CP)
@ -385,10 +385,9 @@ class CarStateBase(ABC):
K = get_kalman_gain(DT_CTRL, np.array(A), np.array(C), np.array(Q), R) K = get_kalman_gain(DT_CTRL, np.array(A), np.array(C), np.array(Q), R)
self.v_ego_kf = KF1D(x0=x0, A=A, C=C[0], K=K) self.v_ego_kf = KF1D(x0=x0, A=A, C=C[0], K=K)
# TODO: this @abstractmethod
# @abstractmethod def update(self, *args) -> structs.CarState:
# def update(self, *args) -> structs.CarState: pass
# raise NotImplementedError
def update_speed_kf(self, v_ego_raw): def update_speed_kf(self, v_ego_raw):
if abs(v_ego_raw - self.v_ego_kf.x[0][0]) > 2.0: # Prevent large accelerations when car starts at non zero speed if abs(v_ego_raw - self.v_ego_kf.x[0][0]) > 2.0: # Prevent large accelerations when car starts at non zero speed

@ -2,9 +2,8 @@ import copy
from opendbc.can.can_define import CANDefine from opendbc.can.can_define import CANDefine
from opendbc.can.parser import CANParser from opendbc.can.parser import CANParser
from openpilot.selfdrive.car import DT_CTRL from openpilot.selfdrive.car import DT_CTRL, structs
from openpilot.selfdrive.car.conversions import Conversions as CV from openpilot.selfdrive.car.conversions import Conversions as CV
from openpilot.selfdrive.car import structs
from openpilot.selfdrive.car.filter_simple import FirstOrderFilter from openpilot.selfdrive.car.filter_simple import FirstOrderFilter
from openpilot.selfdrive.car.helpers import mean from openpilot.selfdrive.car.helpers import mean
from openpilot.selfdrive.car.interfaces import CarStateBase from openpilot.selfdrive.car.interfaces import CarStateBase

@ -1,10 +1,10 @@
from cereal import car from cereal import car
from panda import Panda from panda import Panda
from panda.python import uds from panda.python import uds
from openpilot.selfdrive.car.toyota.carstate import CarState
from openpilot.selfdrive.car.toyota.values import Ecu, CAR, DBC, ToyotaFlags, CarControllerParams, TSS2_CAR, RADAR_ACC_CAR, NO_DSU_CAR, \ 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 import create_button_events, get_safety_config, structs
from openpilot.selfdrive.car import structs
from openpilot.selfdrive.car.disable_ecu import disable_ecu from openpilot.selfdrive.car.disable_ecu import disable_ecu
from openpilot.selfdrive.car.interfaces import CarInterfaceBase from openpilot.selfdrive.car.interfaces import CarInterfaceBase
@ -14,6 +14,8 @@ SteerControlType = structs.CarParams.SteerControlType
class CarInterface(CarInterfaceBase): class CarInterface(CarInterfaceBase):
CS: CarState
@staticmethod @staticmethod
def get_pid_accel_limits(CP, current_speed, cruise_speed): def get_pid_accel_limits(CP, current_speed, cruise_speed):
return CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX return CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX

Loading…
Cancel
Save