add a which enum

pull/33208/head
Shane Smiskol 1 year ago
parent 29e6ecb405
commit 297f5abed8
  1. 2
      selfdrive/car/nissan/carstate.py
  2. 15
      selfdrive/car/structs.py

@ -20,7 +20,7 @@ class CarState(CarStateBase):
self.lkas_hud_msg = {}
self.lkas_hud_info_msg = {}
self.steeringTorqueSamples = deque(TORQUE_SAMPLES*[0], TORQUE_SAMPLES)
self.steeringTorqueSamples = deque(TORQUE_SAMPLES*[0.0], TORQUE_SAMPLES)
self.shifter_values = can_define.dv["GEARBOX"]["GEAR_SHIFTER"]
self.distance_button = 0

@ -318,14 +318,17 @@ class CarParams:
@auto_dataclass
class LateralTuning:
def init(self, _which: str):
assert _which in ('pid', 'torque'), 'Invalid union type'
self._which = _which
def init(self, which: str):
self.which = CarParams.LateralTuning.Which(which)
def which(self):
return self._which
class Which(StrEnum):
pid = auto()
torque = auto()
def __call__(self):
return self.value
_which: str = 'pid'
which: 'CarParams.LateralTuning.Which' = field(default_factory=lambda: CarParams.LateralTuning.Which.torque)
pid: 'CarParams.LateralPIDTuning' = field(default_factory=lambda: CarParams.LateralPIDTuning())
torque: 'CarParams.LateralTorqueTuning' = field(default_factory=lambda: CarParams.LateralTorqueTuning())

Loading…
Cancel
Save