Skip to content

Commit

Permalink
compatibility docs: fixup steering torque star (#24940)
Browse files Browse the repository at this point in the history
* Ascent has good torque, hard code Toyota, print all unexpected torque star cars

* update docs

* Use subtests

* hardcode CHR for now

generate

* Hard code Impreza

* update refs
  • Loading branch information
sshane committed Jun 22, 2022
1 parent f99a091 commit 789f2d1
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 35 deletions.
32 changes: 16 additions & 16 deletions docs/CARS.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion selfdrive/car/subaru/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SubaruCarInfo(CarInfo):


CAR_INFO: Dict[str, Union[SubaruCarInfo, List[SubaruCarInfo]]] = {
CAR.ASCENT: SubaruCarInfo("Subaru Ascent 2019-20", "All"),
CAR.ASCENT: SubaruCarInfo("Subaru Ascent 2019-20", "All", good_torque=True),
CAR.IMPREZA: [
SubaruCarInfo("Subaru Impreza 2017-19"),
SubaruCarInfo("Subaru Crosstrek 2018-19", video_link="https://youtu.be/Agww7oE1k-s?t=26"),
Expand Down
37 changes: 21 additions & 16 deletions selfdrive/car/tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,37 @@ def test_generator(self):
current_cars_md = f.read()

self.assertEqual(generated_cars_md, current_cars_md,
"Run selfdrive/car/docs.py to generate new supported cars documentation")
"Run selfdrive/car/docs.py to update the compatibility documentation")

def test_missing_car_info(self):
all_car_info_platforms = get_interface_attr("CAR_INFO", combine_brands=True).keys()
for platform in sorted(interfaces.keys()):
if platform not in all_car_info_platforms:
self.fail("Platform: {} doesn't exist in CarInfo".format(platform))
with self.subTest(platform=platform):
self.assertTrue(platform in all_car_info_platforms, "Platform: {} doesn't exist in CarInfo".format(platform))

def test_naming_conventions(self):
# Asserts market-standard car naming conventions by make
# Asserts market-standard car naming conventions by brand
for car in self.all_cars:
tokens = car.model.lower().split(" ")
if car.car_name == "hyundai":
self.assertNotIn("phev", tokens, "Use `Plug-in Hybrid`")
self.assertNotIn("hev", tokens, "Use `Hybrid`")
self.assertNotIn("ev", tokens, "Use `Electric`")
if "plug-in hybrid" in car.model.lower():
self.assertIn("Plug-in Hybrid", car.model, "Use correct capitalization")
elif car.car_name == "toyota":
if "rav4" in tokens:
self.assertIn("RAV4", car.model, "Use correct capitalization")
with self.subTest(car=car):
tokens = car.model.lower().split(" ")
if car.car_name == "hyundai":
self.assertNotIn("phev", tokens, "Use `Plug-in Hybrid`")
self.assertNotIn("hev", tokens, "Use `Hybrid`")
self.assertNotIn("ev", tokens, "Use `Electric`")
if "plug-in hybrid" in car.model.lower():
self.assertIn("Plug-in Hybrid", car.model, "Use correct capitalization")
elif car.car_name == "toyota":
if "rav4" in tokens:
self.assertIn("RAV4", car.model, "Use correct capitalization")

def test_torque_star(self):
# Asserts brand-specific assumptions around steering torque star
for car in self.all_cars:
if car.car_name == "honda":
self.assertTrue(car.row[Column.STEERING_TORQUE] in (Star.EMPTY, Star.HALF), f"{car.name} has full torque star")
with self.subTest(car=car):
if car.car_name == "honda":
self.assertIn(car.row[Column.STEERING_TORQUE], (Star.EMPTY, Star.HALF), f"{car.name} has full torque star")
elif car.car_name in ("toyota", "hyundai"):
self.assertNotEqual(car.row[Column.STEERING_TORQUE], Star.EMPTY, f"{car.name} has no torque star")


if __name__ == "__main__":
Expand Down
Loading

0 comments on commit 789f2d1

Please sign in to comment.