diff --git a/selfdrive/car/ford/tests/ford_fuzzy_fingerprint.ipynb b/selfdrive/car/ford/tests/ford_fuzzy_fingerprint.ipynb index 137b5eb814..46ae67825d 100644 --- a/selfdrive/car/ford/tests/ford_fuzzy_fingerprint.ipynb +++ b/selfdrive/car/ford/tests/ford_fuzzy_fingerprint.ipynb @@ -2,9 +2,17 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "kj/filesystem-disk-unix.c++:1703: warning: PWD environment variable doesn't match current directory; pwd = /mnt/c/Users/camer/AppData/Local/Programs/Microsoft VS Code\n" + ] + } + ], "source": [ "from openpilot.tools.lib.comma_car_segments import get_comma_car_segments_database\n", "from openpilot.selfdrive.car.ford.values import CAR\n", @@ -20,85 +28,356 @@ "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "Skipping platform: FORD F-150 14TH GEN, no data available\n" - ] + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "1f0a7e43c6374bafa78941befed85958", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/261 [00:00\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
sourceexpectedfuzzycorrect
0fwFORD BRONCO SPORT 1ST GENFORD BRONCO SPORT 1ST GENTrue
1fwFORD MAVERICK 1ST GENmockFalse
4fwFORD ESCAPE 4TH GENFORD ESCAPE 4TH GENTrue
6fwFORD FOCUS 4TH GENFORD FOCUS 4TH GENTrue
7fixedFORD EXPLORER 6TH GENFORD EXPLORER 6TH GENTrue
10fwFORD EXPLORER 6TH GENFORD EXPLORER 6TH GENTrue
19fwFORD MAVERICK 1ST GENFORD MAVERICK 1ST GENTrue
41fwFORD F-150 LIGHTNING 1ST GENFORD F-150 LIGHTNING 1ST GENTrue
52fixedFORD MAVERICK 1ST GENFORD MAVERICK 1ST GENTrue
113fwFORD MUSTANG MACH-E 1ST GENFORD MUSTANG MACH-E 1ST GENTrue
\n", + "" + ], + "text/plain": [ + " source expected fuzzy \\\n", + "0 fw FORD BRONCO SPORT 1ST GEN FORD BRONCO SPORT 1ST GEN \n", + "1 fw FORD MAVERICK 1ST GEN mock \n", + "4 fw FORD ESCAPE 4TH GEN FORD ESCAPE 4TH GEN \n", + "6 fw FORD FOCUS 4TH GEN FORD FOCUS 4TH GEN \n", + "7 fixed FORD EXPLORER 6TH GEN FORD EXPLORER 6TH GEN \n", + "10 fw FORD EXPLORER 6TH GEN FORD EXPLORER 6TH GEN \n", + "19 fw FORD MAVERICK 1ST GEN FORD MAVERICK 1ST GEN \n", + "41 fw FORD F-150 LIGHTNING 1ST GEN FORD F-150 LIGHTNING 1ST GEN \n", + "52 fixed FORD MAVERICK 1ST GEN FORD MAVERICK 1ST GEN \n", + "113 fw FORD MUSTANG MACH-E 1ST GEN FORD MUSTANG MACH-E 1ST GEN \n", + "\n", + " correct \n", + "0 True \n", + "1 False \n", + "4 True \n", + "6 True \n", + "7 True \n", + "10 True \n", + "19 True \n", + "41 True \n", + "52 True \n", + "113 True " + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ + "import pandas as pd\n", + "\n", "from openpilot.selfdrive.car.fw_versions import build_fw_dict\n", - "from openpilot.selfdrive.car.ford.values import match_fw_to_car_fuzzy\n", "from openpilot.selfdrive.car.ford.fingerprints import FW_VERSIONS\n", + "from openpilot.selfdrive.car.ford.values import match_fw_to_car_fuzzy\n", "\n", + "rows = []\n", "success, count = 0, 0\n", - "for vin, car_fw, expected_platform, fuzzy, surce in FW_TO_CHECK:\n", + "for vin, car_fw, expected_platform, fuzzy, source in FW_TO_CHECK:\n", + " car_fw = list(filter(lambda fw: fw.brand == \"ford\" and not fw.logging, car_fw))\n", " if len(car_fw) == 0:\n", " print(f\"Skipping vin: {vin} platform: {expected_platform}, no car fw\")\n", " continue\n", - " car_fw = build_fw_dict(car_fw)\n", - " fuzzy_fingerprint = match_fw_to_car_fuzzy(car_fw, FW_VERSIONS)\n", + "\n", + " fuzzy_fingerprint = match_fw_to_car_fuzzy(build_fw_dict(car_fw), FW_VERSIONS)\n", " if len(fuzzy_fingerprint) == 0:\n", " fuzzy_fingerprint = \"mock\"\n", " elif len(fuzzy_fingerprint) > 1:\n", @@ -107,15 +386,14 @@ " fuzzy_fingerprint = list(fuzzy_fingerprint)[0]\n", "\n", " correct = fuzzy_fingerprint == expected_platform\n", - " print(f\"vin: {vin} expected: {expected_platform: <30} fuzzy: {fuzzy_fingerprint: <30} correct: {correct}\")\n", + " rows.append((source, expected_platform, fuzzy_fingerprint, correct))\n", " if not correct:\n", - " print(f\" source: {surce}\")\n", + " print(f\"vin: {vin} expected: {expected_platform: <30} fuzzy: {fuzzy_fingerprint: <30} correct: {correct}\")\n", + " print(f\" source: {source}\")\n", " print(f\" fuzzy: {fuzzy}\")\n", " print(\" car_fw:\")\n", " fws = set()\n", " for fw in car_fw:\n", - " if fw.brand != \"ford\" or fw.logging:\n", - " continue\n", " fw_version = fw.fwVersion.rstrip(b\"\\0\")\n", " fws.add(f\"{fw.ecu} {fw_version}\")\n", " for fw in sorted(fws):\n", @@ -123,8 +401,20 @@ " success += correct\n", " count += 1\n", "\n", - "print(f\"Success rate: {success / count * 100:.2f}%\")" + "print(f\"Success rate: {success / count * 100:.2f}%\")\n", + "\n", + "pd.set_option(\"display.max_rows\", None)\n", + "\n", + "df = pd.DataFrame(rows, columns=[\"source\", \"expected\", \"fuzzy\", \"correct\"]).drop_duplicates()\n", + "df" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": {