|
|
|
@ -2,7 +2,7 @@ import yaml |
|
|
|
|
import os |
|
|
|
|
import time |
|
|
|
|
from abc import abstractmethod, ABC |
|
|
|
|
from typing import Any, Dict, Tuple, List |
|
|
|
|
from typing import Any, Dict, Optional, Tuple, List |
|
|
|
|
|
|
|
|
|
from cereal import car |
|
|
|
|
from common.basedir import BASEDIR |
|
|
|
@ -318,13 +318,22 @@ class CarStateBase(ABC): |
|
|
|
|
return bool(left_blinker_stalk or self.left_blinker_cnt > 0), bool(right_blinker_stalk or self.right_blinker_cnt > 0) |
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
|
def parse_gear_shifter(gear: str) -> car.CarState.GearShifter: |
|
|
|
|
def parse_gear_shifter(gear: Optional[str]) -> car.CarState.GearShifter: |
|
|
|
|
if gear is None: |
|
|
|
|
return GearShifter.unknown |
|
|
|
|
|
|
|
|
|
d: Dict[str, car.CarState.GearShifter] = { |
|
|
|
|
'P': GearShifter.park, 'R': GearShifter.reverse, 'N': GearShifter.neutral, |
|
|
|
|
'E': GearShifter.eco, 'T': GearShifter.manumatic, 'D': GearShifter.drive, |
|
|
|
|
'S': GearShifter.sport, 'L': GearShifter.low, 'B': GearShifter.brake |
|
|
|
|
'P': GearShifter.park, 'PARK': GearShifter.park, |
|
|
|
|
'R': GearShifter.reverse, 'REVERSE': GearShifter.reverse, |
|
|
|
|
'N': GearShifter.neutral, 'NEUTRAL': GearShifter.neutral, |
|
|
|
|
'E': GearShifter.eco, 'ECO': GearShifter.eco, |
|
|
|
|
'T': GearShifter.manumatic, 'MANUAL': GearShifter.manumatic, |
|
|
|
|
'D': GearShifter.drive, 'DRIVE': GearShifter.drive, |
|
|
|
|
'S': GearShifter.sport, 'SPORT': GearShifter.sport, |
|
|
|
|
'L': GearShifter.low, 'LOW': GearShifter.low, |
|
|
|
|
'B': GearShifter.brake, 'BRAKE': GearShifter.brake, |
|
|
|
|
} |
|
|
|
|
return d.get(gear, GearShifter.unknown) |
|
|
|
|
return d.get(gear.upper(), GearShifter.unknown) |
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
|
def get_cam_can_parser(CP): |
|
|
|
|