From 040223e69ff8aa5383519d0b42a2a36c9e3882b1 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Fri, 5 Jan 2024 14:53:03 -0500 Subject: [PATCH] move car porting tools to tools/car_porting (#30916) just this for now old-commit-hash: e86d74b347f60a3e575d45b4c99d94d23c8c7d84 --- selfdrive/car/README.md | 60 ------------------- tools/car_porting/README.md | 58 ++++++++++++++++++ .../car_porting}/auto_fingerprint.py | 0 .../car_porting}/test_car_model.py | 0 4 files changed, 58 insertions(+), 60 deletions(-) create mode 100644 tools/car_porting/README.md rename {selfdrive/debug => tools/car_porting}/auto_fingerprint.py (100%) rename {selfdrive/debug => tools/car_porting}/test_car_model.py (100%) diff --git a/selfdrive/car/README.md b/selfdrive/car/README.md index f77bea205b..2c49cf2051 100644 --- a/selfdrive/car/README.md +++ b/selfdrive/car/README.md @@ -1,63 +1,3 @@ -# selfdrive/car - -Check out [this blog post](https://blog.comma.ai/how-to-write-a-car-port-for-openpilot/) for a high-level overview of porting a car. - -## Useful car porting utilities - -Testing car ports in your car is very time-consuming. Check out these utilities to do basic checks on your work before running it in your car. - -### [Cabana](/tools/cabana/README.md) - -View your car's CAN signals through DBC files, which openpilot uses to parse and create messages that talk to the car. - -Example: -```bash -> tools/cabana/cabana '1bbe6bf2d62f58a8|2022-07-14--17-11-43' -``` - -### [selfdrive/debug/auto_fingerprint.py](/selfdrive/debug/auto_fingerprint.py) - -Given a route and platform, automatically inserts FW fingerprints from the platform into the correct place in values.py - -Example: -```bash -> python selfdrive/debug/auto_fingerprint.py '1bbe6bf2d62f58a8|2022-07-14--17-11-43' 'SUBARU OUTBACK 6TH GEN' -Attempting to add fw version for: SUBARU OUTBACK 6TH GEN -``` - -### [selfdrive/car/tests/test_car_interfaces.py](/selfdrive/car/tests/test_car_interfaces.py) - -Finds common bugs for car interfaces, without even requiring a route. - - -#### Example: Typo in signal name -```bash -> pytest selfdrive/car/tests/test_car_interfaces.py -k subaru # replace with the brand you are working on - -===================================================================== -FAILED selfdrive/car/tests/test_car_interfaces.py::TestCarInterfaces::test_car_interfaces_165_SUBARU_LEGACY_7TH_GEN - KeyError: 'CruiseControlOOPS' - -``` - -### [selfdrive/debug/test_car_model.py](/selfdrive/debug/test_car_model.py) - -Given a route, runs most of the car interface to check for common errors like missing signals, blocked panda messages, and safety mismatches. - -#### Example: panda safety mismatch for gasPressed -```bash -> python selfdrive/debug/test_car_model.py '4822a427b188122a|2023-08-14--16-22-21' - -===================================================================== -FAIL: test_panda_safety_carstate (__main__.CarModelTestCase.test_panda_safety_carstate) -Assert that panda safety matches openpilot's carState ----------------------------------------------------------------------- -Traceback (most recent call last): - File "/home/batman/xx/openpilot/openpilot/selfdrive/car/tests/test_models.py", line 380, in test_panda_safety_carstate - self.assertFalse(len(failed_checks), f"panda safety doesn't agree with openpilot: {failed_checks}") -AssertionError: 1 is not false : panda safety doesn't agree with openpilot: {'gasPressed': 116} -``` - - ## Car port structure ### interface.py diff --git a/tools/car_porting/README.md b/tools/car_porting/README.md new file mode 100644 index 0000000000..14e6c71e58 --- /dev/null +++ b/tools/car_porting/README.md @@ -0,0 +1,58 @@ +# tools/car_porting + +Check out [this blog post](https://blog.comma.ai/how-to-write-a-car-port-for-openpilot/) for a high-level overview of porting a car. + +## Useful car porting utilities + +Testing car ports in your car is very time-consuming. Check out these utilities to do basic checks on your work before running it in your car. + +### [Cabana](/tools/cabana/README.md) + +View your car's CAN signals through DBC files, which openpilot uses to parse and create messages that talk to the car. + +Example: +```bash +> tools/cabana/cabana '1bbe6bf2d62f58a8|2022-07-14--17-11-43' +``` + +### [tools/car_porting/auto_fingerprint.py](/tools/car_porting/auto_fingerprint.py) + +Given a route and platform, automatically inserts FW fingerprints from the platform into the correct place in fingerprints.py + +Example: +```bash +> python tools/car_porting/auto_fingerprint.py '1bbe6bf2d62f58a8|2022-07-14--17-11-43' 'SUBARU OUTBACK 6TH GEN' +Attempting to add fw version for: SUBARU OUTBACK 6TH GEN +``` + +### [selfdrive/car/tests/test_car_interfaces.py](/selfdrive/car/tests/test_car_interfaces.py) + +Finds common bugs for car interfaces, without even requiring a route. + + +#### Example: Typo in signal name +```bash +> pytest selfdrive/car/tests/test_car_interfaces.py -k subaru # replace with the brand you are working on + +===================================================================== +FAILED selfdrive/car/tests/test_car_interfaces.py::TestCarInterfaces::test_car_interfaces_165_SUBARU_LEGACY_7TH_GEN - KeyError: 'CruiseControlOOPS' + +``` + +### [tools/car_porting/test_car_model.py](/tools/car_porting/test_car_model.py) + +Given a route, runs most of the car interface to check for common errors like missing signals, blocked panda messages, and safety mismatches. + +#### Example: panda safety mismatch for gasPressed +```bash +> python tools/car_porting/test_car_model.py '4822a427b188122a|2023-08-14--16-22-21' + +===================================================================== +FAIL: test_panda_safety_carstate (__main__.CarModelTestCase.test_panda_safety_carstate) +Assert that panda safety matches openpilot's carState +---------------------------------------------------------------------- +Traceback (most recent call last): + File "/home/batman/xx/openpilot/openpilot/selfdrive/car/tests/test_models.py", line 380, in test_panda_safety_carstate + self.assertFalse(len(failed_checks), f"panda safety doesn't agree with openpilot: {failed_checks}") +AssertionError: 1 is not false : panda safety doesn't agree with openpilot: {'gasPressed': 116} +``` \ No newline at end of file diff --git a/selfdrive/debug/auto_fingerprint.py b/tools/car_porting/auto_fingerprint.py similarity index 100% rename from selfdrive/debug/auto_fingerprint.py rename to tools/car_porting/auto_fingerprint.py diff --git a/selfdrive/debug/test_car_model.py b/tools/car_porting/test_car_model.py similarity index 100% rename from selfdrive/debug/test_car_model.py rename to tools/car_porting/test_car_model.py