pull/24020/head
Shane Smiskol 3 years ago
parent a3951dde26
commit 2c3c5c476e
  1. 1926
      docs/vehicles.vue
  2. 6
      scripts/count_cars.py
  3. 14
      selfdrive/car/docs.py
  4. 85
      selfdrive/car/docs_definitions.py
  5. 4
      selfdrive/car/tests/test_docs.py

File diff suppressed because it is too large Load Diff

@ -2,12 +2,12 @@
from collections import Counter
from pprint import pprint
from selfdrive.car.docs import get_tier_car_rows
from selfdrive.car.docs import get_tier_car_info
if __name__ == "__main__":
tiers = list(get_tier_car_rows())
tiers = get_tier_car_info()
cars = [car for tier_cars in tiers for car in tier_cars[1]]
make_count = Counter(l[0] for l in cars)
make_count = Counter(l.make for l in cars)
print("\n", "*" * 20, len(cars), "total", "*" * 20, "\n")
pprint(make_count)

@ -3,16 +3,16 @@ import argparse
import jinja2
import os
from enum import Enum
from typing import Dict, Iterator, List, Tuple
from typing import Dict, List, Tuple
from common.basedir import BASEDIR
from selfdrive.car.docs_definitions import Column, CarInfo, Star, Tier
from selfdrive.car.docs_definitions import CarInfo, Column, Star, Tier
from selfdrive.car.car_helpers import interfaces, get_interface_attr
from selfdrive.car.hyundai.radar_interface import RADAR_START_ADDR as HKG_RADAR_START_ADDR
from selfdrive.car.tests.routes import non_tested_cars
def get_all_footnotes():
def get_all_footnotes() -> Dict[Enum, int]:
all_footnotes = []
for _, footnotes in get_interface_attr("Footnote").items():
if footnotes is not None:
@ -25,7 +25,7 @@ CARS_MD_OUT = os.path.join(BASEDIR, "docs", "CARS.md")
CARS_MD_TEMPLATE = os.path.join(BASEDIR, "selfdrive", "car", "CARS_template.md")
def get_tier_car_info() -> List[Tuple[Tier, List[CarInfo]]]: # TODO: update typing for all this
def get_tier_car_info() -> List[Tuple[Tier, List[CarInfo]]]:
tier_car_info: Dict[Tier, list] = {tier: [] for tier in Tier}
for models in get_interface_attr("CAR_INFO").values():
@ -47,8 +47,8 @@ def get_tier_car_info() -> List[Tuple[Tier, List[CarInfo]]]: # TODO: update typ
# Return tier enum and car rows for each tier
tiers = []
for tier, car_rows in tier_car_info.items():
tiers.append((tier, sorted(car_rows, key=lambda x: x.make + x.model)))
for tier, cars in tier_car_info.items():
tiers.append((tier, sorted(cars, key=lambda x: x.make + x.model)))
return tiers
@ -57,7 +57,7 @@ def generate_cars_md(tier_car_info: List[Tuple[Tier, List[CarInfo]]], template_f
template = jinja2.Template(f.read(), trim_blocks=True, lstrip_blocks=True)
footnotes = [fn.value.text for fn in ALL_FOOTNOTES]
return template.render(tiers=tier_car_info, Star=Star, Column=Column, footnotes=footnotes)
return template.render(tiers=tier_car_info, footnotes=footnotes, Star=Star, Column=Column)
if __name__ == "__main__":

@ -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

@ -1,12 +1,12 @@
#!/usr/bin/env python3
import unittest
from selfdrive.car.docs import CARS_MD_OUT, CARS_MD_TEMPLATE, generate_cars_md, get_tier_car_rows
from selfdrive.car.docs import CARS_MD_OUT, CARS_MD_TEMPLATE, generate_cars_md, get_tier_car_info
class TestCarDocs(unittest.TestCase):
def test_car_docs(self):
generated_cars_md = generate_cars_md(get_tier_car_rows(), CARS_MD_TEMPLATE)
generated_cars_md = generate_cars_md(get_tier_car_info(), CARS_MD_TEMPLATE)
with open(CARS_MD_OUT, "r") as f:
current_cars_md = f.read()

Loading…
Cancel
Save