mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-07 14:42:08 +08:00
Typing experiments (#1633)
* add more types * car * no abc Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> old-commit-hash: 40acdc4524eb5d3365c363ac7441daf407f4adbd
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
import os
|
||||
import time
|
||||
from typing import Dict
|
||||
|
||||
from cereal import car
|
||||
from common.kalman.simple_kalman import KF1D
|
||||
from common.realtime import DT_CTRL
|
||||
from selfdrive.car import gen_empty_fingerprint
|
||||
from selfdrive.config import Conversions as CV
|
||||
from selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX
|
||||
from selfdrive.controls.lib.events import Events
|
||||
from selfdrive.controls.lib.vehicle_model import VehicleModel
|
||||
from selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX
|
||||
|
||||
GearShifter = car.CarState.GearShifter
|
||||
EventName = car.CarEvent.EventName
|
||||
@@ -15,6 +17,7 @@ MAX_CTRL_SPEED = (V_CRUISE_MAX + 4) * CV.KPH_TO_MS # 144 + 4 = 92 mph
|
||||
|
||||
# generic car and radar interfaces
|
||||
|
||||
|
||||
class CarInterfaceBase():
|
||||
def __init__(self, CP, CarController, CarState):
|
||||
self.CP = CP
|
||||
@@ -132,6 +135,7 @@ class CarInterfaceBase():
|
||||
|
||||
return events
|
||||
|
||||
|
||||
class RadarInterfaceBase():
|
||||
def __init__(self, CP):
|
||||
self.pts = {}
|
||||
@@ -145,6 +149,7 @@ class RadarInterfaceBase():
|
||||
time.sleep(self.radar_ts) # radard runs on RI updates
|
||||
return ret
|
||||
|
||||
|
||||
class CarStateBase:
|
||||
def __init__(self, CP):
|
||||
self.CP = CP
|
||||
@@ -175,10 +180,13 @@ class CarStateBase:
|
||||
return self.left_blinker_cnt > 0, self.right_blinker_cnt > 0
|
||||
|
||||
@staticmethod
|
||||
def parse_gear_shifter(gear):
|
||||
return {'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}.get(gear, GearShifter.unknown)
|
||||
def parse_gear_shifter(gear: str) -> car.CarState.GearShifter:
|
||||
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
|
||||
}
|
||||
return d.get(gear, GearShifter.unknown)
|
||||
|
||||
@staticmethod
|
||||
def get_cam_can_parser(CP):
|
||||
|
||||
@@ -34,7 +34,8 @@ class ET:
|
||||
PERMANENT = 'permanent'
|
||||
|
||||
# get event name from enum
|
||||
EVENT_NAME = {v: k for k, v in EventName.schema.enumerants.items()}
|
||||
EVENT_NAME = {v: k for k, v in EventName.schema.enumerants.items()} # type: ignore
|
||||
|
||||
|
||||
class Events:
|
||||
def __init__(self):
|
||||
|
||||
@@ -12,11 +12,12 @@ x_dot = A*x + B*u
|
||||
|
||||
A depends on longitudinal speed, u [m/s], and vehicle parameters CP
|
||||
"""
|
||||
from typing import Tuple
|
||||
|
||||
import numpy as np
|
||||
from numpy.linalg import solve
|
||||
from typing import Tuple
|
||||
from cereal import car
|
||||
|
||||
from cereal import car
|
||||
|
||||
class VehicleModel:
|
||||
def __init__(self, CP: car.CarParams):
|
||||
|
||||
Reference in New Issue
Block a user