|
|
|
@ -1,7 +1,45 @@ |
|
|
|
|
from cereal import car |
|
|
|
|
from collections import namedtuple |
|
|
|
|
from dataclasses import dataclass |
|
|
|
|
from enum import Enum |
|
|
|
|
from typing import List, Optional |
|
|
|
|
from typing import Dict, List, Optional, Union |
|
|
|
|
import typing |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Tier(Enum): |
|
|
|
|
GOLD = "The best openpilot experience. Great highway driving and beyond." |
|
|
|
|
SILVER = "A solid highway driving experience, but is limited by stock longitudinal. May be upgraded in the future." |
|
|
|
|
BRONZE = "A good highway experience, but may have limited performance in traffic and on sharp turns." |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Column(Enum): |
|
|
|
|
MAKE = "Make" |
|
|
|
|
MODEL = "Model" |
|
|
|
|
PACKAGE = "Supported Package" |
|
|
|
|
LONGITUDINAL = "openpilot ACC" |
|
|
|
|
FSR_LONGITUDINAL = "Stop and Go" |
|
|
|
|
FSR_STEERING = "Steer to 0" |
|
|
|
|
STEERING_TORQUE = "Steering Torque" |
|
|
|
|
MAINTAINED = "Actively Maintained" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Star(Enum): |
|
|
|
|
FULL = "full" |
|
|
|
|
HALF = "half" |
|
|
|
|
EMPTY = "empty" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StarColumns = list(Column)[3:] |
|
|
|
|
CarFootnote = namedtuple("CarFootnote", ["text", "column", "star"], defaults=[None]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_footnote(footnotes: Optional[List[Enum]], column: Column) -> Optional[Enum]: |
|
|
|
|
# Returns applicable footnote given current column |
|
|
|
|
if footnotes is not None: |
|
|
|
|
for fn in footnotes: |
|
|
|
|
if fn.value.column == column: |
|
|
|
|
return fn |
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass |
|
|
|
@ -14,7 +52,7 @@ class CarInfo: |
|
|
|
|
min_enable_speed: Optional[float] = None |
|
|
|
|
good_torque: bool = False |
|
|
|
|
|
|
|
|
|
def init(self, CP, non_tested_cars, all_footnotes): |
|
|
|
|
def init(self, CP: car.CarParams, non_tested_cars: List[str], all_footnotes: Dict[Enum, int]): |
|
|
|
|
# TODO: set all the min steer speeds in carParams and remove this |
|
|
|
|
min_steer_speed = CP.minSteerSpeed |
|
|
|
|
if self.min_steer_speed is not None: |
|
|
|
@ -50,9 +88,10 @@ class CarInfo: |
|
|
|
|
|
|
|
|
|
self.tier = {5: Tier.GOLD, 4: Tier.SILVER}.get(list(self.row.values()).count(Star.FULL), Tier.BRONZE) |
|
|
|
|
|
|
|
|
|
def get_column(self, column, star_icon, footnote_tag): |
|
|
|
|
item = self.row[column] |
|
|
|
|
if column in StarColumns: |
|
|
|
|
@typing.no_type_check |
|
|
|
|
def get_column(self, column: Column, star_icon: str, footnote_tag: str) -> str: |
|
|
|
|
item: Union[str, Star] = self.row[column] |
|
|
|
|
if item in StarColumns: |
|
|
|
|
item = star_icon.format(item.value) |
|
|
|
|
|
|
|
|
|
footnote = get_footnote(self.footnotes, column) |
|
|
|
@ -60,39 +99,3 @@ class CarInfo: |
|
|
|
|
item += footnote_tag.format(self.all_footnotes[footnote]) |
|
|
|
|
|
|
|
|
|
return item |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Tier(Enum): |
|
|
|
|
GOLD = "The best openpilot experience. Great highway driving and beyond." |
|
|
|
|
SILVER = "A solid highway driving experience, but is limited by stock longitudinal. May be upgraded in the future." |
|
|
|
|
BRONZE = "A good highway experience, but may have limited performance in traffic and on sharp turns." |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Column(Enum): |
|
|
|
|
MAKE = "Make" |
|
|
|
|
MODEL = "Model" |
|
|
|
|
PACKAGE = "Supported Package" |
|
|
|
|
LONGITUDINAL = "openpilot ACC" |
|
|
|
|
FSR_LONGITUDINAL = "Stop and Go" |
|
|
|
|
FSR_STEERING = "Steer to 0" |
|
|
|
|
STEERING_TORQUE = "Steering Torque" |
|
|
|
|
MAINTAINED = "Actively Maintained" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Star(Enum): |
|
|
|
|
FULL = "full" |
|
|
|
|
HALF = "half" |
|
|
|
|
EMPTY = "empty" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StarColumns = list(Column)[3:] |
|
|
|
|
CarFootnote = namedtuple("CarFootnote", ["text", "column", "star"], defaults=[None]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_footnote(footnotes: Optional[List[Enum]], column: Column) -> Optional[Enum]: |
|
|
|
|
# Returns applicable footnote given current column |
|
|
|
|
if footnotes is not None: |
|
|
|
|
for fn in footnotes: |
|
|
|
|
if fn.value.column == column: |
|
|
|
|
return fn |
|
|
|
|
return None |
|
|
|
|