diff --git a/tools/car_porting/examples/find_segments_with_message.ipynb b/tools/car_porting/examples/find_segments_with_message.ipynb new file mode 100644 index 0000000000..82b06c1f31 --- /dev/null +++ b/tools/car_porting/examples/find_segments_with_message.ipynb @@ -0,0 +1,279 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 30, + "id": "228a6736-de31-4255-9d72-a6ff391b968d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Found 221 qualifying vehicles:\n" + ] + } + ], + "source": [ + "from opendbc.car import structs\n", + "from opendbc.car.values import PLATFORMS\n", + "\n", + "print(f\"Found {len(PLATFORMS)} qualifying vehicles:\")\n", + "# for platform in PLATFORMS:\n", + "# print(f\" {platform}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "ed1c8aec-c274-4c61-b83d-711ea194bf86", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting segments from commaCarSegments dataset:\n", + "No segments available for for DODGE_DURANGO\n", + "No segments available for for FORD_RANGER_MK2\n", + "No segments available for for HOLDEN_ASTRA\n", + "No segments available for for CADILLAC_ATS\n", + "No segments available for for CHEVROLET_MALIBU\n", + "No segments available for for CADILLAC_XT4\n", + "No segments available for for CHEVROLET_VOLT_2019\n", + "No segments available for for CHEVROLET_TRAVERSE\n", + "No segments available for for GMC_YUKON\n", + "No segments available for for HONDA_ODYSSEY_CHN\n", + "No segments available for for HYUNDAI_KONA_2022\n", + "No segments available for for HYUNDAI_NEXO_1ST_GEN\n", + "No segments available for for GENESIS_GV70_ELECTRIFIED_1ST_GEN\n", + "No segments available for for GENESIS_G80_2ND_GEN_FL\n", + "No segments available for for RIVIAN_R1_GEN1\n", + "No segments available for for SUBARU_FORESTER_HYBRID\n", + "No segments available for for TESLA_MODEL_3\n", + "No segments available for for TESLA_MODEL_Y\n", + "No segments available for for TOYOTA_RAV4_PRIME\n", + "No segments available for for TOYOTA_SIENNA_4TH_GEN\n", + "No segments available for for LEXUS_LC_TSS2\n", + "No segments available for for VOLKSWAGEN_CADDY_MK3\n", + "No segments available for for VOLKSWAGEN_CRAFTER_MK2\n", + "No segments available for for VOLKSWAGEN_JETTA_MK6\n", + "Collected 577 segments for analysis\n" + ] + } + ], + "source": [ + "import random\n", + "\n", + "from openpilot.tools.lib.logreader import LogReader\n", + "from openpilot.tools.lib.comma_car_segments import get_comma_car_segments_database\n", + "\n", + "database = get_comma_car_segments_database()\n", + "TEST_SEGMENTS = []\n", + "\n", + "MAX_SEGS_PER_PLATFORM = 3 # Increase this to search more segments\n", + "\n", + "print(\"Collecting segments from commaCarSegments dataset:\")\n", + "for platform in TEST_PLATFORMS:\n", + " if platform not in database:\n", + " print(f\"No segments available for for {platform}\")\n", + " continue\n", + " \n", + " all_segments = database[platform]\n", + "\n", + " NUM_SEGMENTS = min(len(all_segments), MAX_SEGS_PER_PLATFORM)\n", + "\n", + " # print(f\"Got {len(all_segments)} segments for platform {platform}, sampling {NUM_SEGMENTS} segments\")\n", + " TEST_SEGMENTS.extend(random.sample(all_segments, NUM_SEGMENTS))\n", + "\n", + "print(f\"Collected {len(TEST_SEGMENTS)} segments for analysis\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "id": "0c75e8f2-4f5f-4f89-b8db-5223a6534a9f", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Match found in d753e5427226080e/2023-12-30--10-14-03/9/s for CHRYSLER PACIFICA HYBRID 2018\n", + "Match found in 810855dc1450c716/2023-12-26--10-03-20/3/s for CHRYSLER PACIFICA HYBRID 2018\n", + "Match found in 7f268b92fc672c4d/2023-11-02--20-54-34/103/s for CHRYSLER PACIFICA HYBRID 2018\n", + "Match found in 1a10807c60c127fd/2023-12-09--19-21-30/49/s for CHRYSLER PACIFICA HYBRID 2019\n", + "Match found in b70b56b76a6217f2/2023-12-26--12-29-24/4/s for CHRYSLER PACIFICA HYBRID 2019\n", + "Match found in 86deeb65f10c3129/2023-12-29--07-38-12/179/s for CHRYSLER PACIFICA HYBRID 2019\n", + "Match found in 0a3e89f78b1d0071/2023-11-30--10-33-13/13/s for CHRYSLER PACIFICA 2018\n", + "Match found in 8fc6a1b72c8b1357/2023-11-30--17-35-04/10/s for CHRYSLER PACIFICA 2018\n", + "Match found in d5de6f3e9371e89e/2023-11-16--17-19-54/48/s for CHRYSLER PACIFICA 2018\n", + "Match found in 5fc1717be83fc0da/2024-01-03--13-16-03/27/s for CHRYSLER PACIFICA 2020\n", + "Match found in c1feb10d20626c65/2023-12-16--17-46-24/9/s for CHRYSLER PACIFICA 2020\n", + "Match found in c1feb10d20626c65/2023-11-21--17-40-18/25/s for CHRYSLER PACIFICA 2020\n", + "Match found in a63a23c3e628f288/2023-11-05--18-36-20/22/s for JEEP GRAND CHEROKEE V6 2018\n", + "Match found in 46b21f1c5f7aa885/2023-11-14--15-22-04/21/s for JEEP GRAND CHEROKEE V6 2018\n", + "Match found in a63a23c3e628f288/2023-12-13--09-15-47/27/s for JEEP GRAND CHEROKEE V6 2018\n", + "Match found in 4ffe7a3fb831a625/2024-01-04--09-15-33/22/s for JEEP GRAND CHEROKEE 2019\n", + "Match found in c5b49919572d2c5a/2023-12-17--15-54-06/73/s for JEEP GRAND CHEROKEE 2019\n", + "Match found in 9c2b832d06f93621/2024-01-25--13-52-19/8/s for JEEP GRAND CHEROKEE 2019\n", + "Match found in 1618132d68afc876/2023-11-24--10-21-12/4/s for HYUNDAI KONA ELECTRIC 2ND GEN\n", + "Match found in 1618132d68afc876/2023-08-27--09-32-14/13/s for HYUNDAI KONA 2ND GEN\n", + "Match found in 1618132d68afc876/2023-11-24--10-21-12/3/s for HYUNDAI KONA ELECTRIC 2ND GEN\n", + "Match found in df7fdd56970d90fe/2023-12-29--07-48-56/53/s for HYUNDAI IONIQ 6 2023\n", + "Match found in 0ad7facc77922c3e/2023-12-29--17-12-45/14/s for HYUNDAI IONIQ 6 2023\n", + "Match found in 0ad7facc77922c3e/2023-12-16--08-49-13/39/s for HYUNDAI IONIQ 6 2023\n", + "Match found in 78ad5150de133637/2023-09-13--16-15-57/0/s for KIA K8 HYBRID 1ST GEN\n", + "Match found in 78ad5150de133637/2023-09-13--16-15-57/2/s for KIA K8 HYBRID 1ST GEN\n", + "Match found in 78ad5150de133637/2023-09-13--16-15-57/1/s for KIA K8 HYBRID 1ST GEN\n", + "Match found in b153671049a867b3/2023-12-15--20-40-16/0/s for KIA NIRO EV 2ND GEN\n", + "Match found in b153671049a867b3/2024-01-12--17-43-31/2/s for KIA NIRO EV 2ND GEN\n", + "Match found in b153671049a867b3/2023-12-03--21-08-30/3/s for KIA NIRO EV 2ND GEN\n", + "Match found in 7387ab2a564c6d9f/2023-12-02--07-10-34/52/s for KIA NIRO HYBRID 2ND GEN\n", + "Match found in 7387ab2a564c6d9f/2024-01-06--16-24-36/1/s for KIA NIRO HYBRID 2ND GEN\n", + "Match found in 7387ab2a564c6d9f/2024-01-06--16-24-36/9/s for KIA NIRO HYBRID 2ND GEN\n", + "Match found in 2efdac7dc41207f1/2023-12-27--07-24-22/89/s for KIA EV6 2022\n", + "Match found in 5ac586afbb236b5d/2023-12-05--18-23-10/7/s for VOLKSWAGEN ARTEON 1ST GEN\n", + "Match found in c34ef43981b6d888/2024-01-18--16-00-06/9/s for VOLKSWAGEN ARTEON 1ST GEN\n", + "Match found in 5ac586afbb236b5d/2024-01-04--20-01-19/4/s for VOLKSWAGEN ARTEON 1ST GEN\n", + "Match found in 16758e226aa2f747/2023-12-16--10-24-39/13/s for VOLKSWAGEN ATLAS 1ST GEN\n", + "Match found in 3174d252cec3bf6f/2023-12-12--18-39-06/6/s for VOLKSWAGEN ATLAS 1ST GEN\n", + "Match found in e80066d826c705a9/2024-01-06--17-28-45/211/s for VOLKSWAGEN ATLAS 1ST GEN\n", + "Match found in 2cdded3a5da75b6a/2024-01-06--13-37-16/2/s for VOLKSWAGEN GOLF 7TH GEN\n", + "Match found in abe0b7fe730c51a9/2023-10-30--14-24-49/4/s for VOLKSWAGEN GOLF 7TH GEN\n", + "Match found in 8fe9ced03c94e256/2023-12-14--16-31-55/8/s for VOLKSWAGEN GOLF 7TH GEN\n", + "Match found in a97d27ce2a78958a/2024-01-09--06-57-35/9/s for VOLKSWAGEN JETTA 7TH GEN\n", + "Match found in 0649d406184b7131/2024-01-20--14-43-41/3/s for VOLKSWAGEN JETTA 7TH GEN\n", + "Match found in 0649d406184b7131/2023-11-07--16-30-10/17/s for VOLKSWAGEN JETTA 7TH GEN\n", + "Match found in 5405cac0c9d58c3d/2023-11-05--17-13-17/6/s for VOLKSWAGEN PASSAT 8TH GEN\n", + "Match found in 2d7d87433a67c925/2024-01-05--16-31-16/38/s for VOLKSWAGEN PASSAT 8TH GEN\n", + "Match found in 2d7d87433a67c925/2023-12-26--08-44-17/2/s for VOLKSWAGEN PASSAT 8TH GEN\n", + "Match found in 0cd0b7f7e31a3853/2021-11-03--19-30-22/0/s for SKODA KODIAQ 1ST GEN\n", + "Match found in 0bbe367c98fa1538/2023-07-01--19-42-26/7/s for VOLKSWAGEN POLO 6TH GEN\n", + "Match found in 0cd0b7f7e31a3853/2021-11-03--19-30-22/2/s for SKODA KODIAQ 1ST GEN\n", + "Match found in 7d82b2f3a9115f1f/2021-10-21--15-39-42/1/s for VOLKSWAGEN TAOS 1ST GEN\n", + "Match found in 7d82b2f3a9115f1f/2021-10-21--15-39-42/0/s for VOLKSWAGEN TAOS 1ST GEN\n", + "Match found in 7d82b2f3a9115f1f/2021-10-21--15-39-42/2/s for VOLKSWAGEN TAOS 1ST GEN\n", + "Match found in 2744c89a8dda9a51/2021-07-24--21-28-06/0/s for SKODA KODIAQ 1ST GEN\n", + "Match found in 2744c89a8dda9a51/2021-07-24--21-28-06/2/s for SKODA KODIAQ 1ST GEN\n", + "Match found in 2744c89a8dda9a51/2021-07-24--21-28-06/1/s for SKODA KODIAQ 1ST GEN\n", + "Match found in 4e144f64a2535890/2023-12-05--12-22-10/5/s for VOLKSWAGEN TIGUAN 2ND GEN\n", + "Match found in 1b5cf3b409037cc4/2023-12-11--10-23-35/5/s for VOLKSWAGEN TIGUAN 2ND GEN\n", + "Match found in 1b41980e9972d348/2023-10-29--15-13-08/3/s for VOLKSWAGEN TIGUAN 2ND GEN\n", + "Match found in a589dcc642fdb10a/2021-06-14--20-54-26/0/s for VOLKSWAGEN TOURAN 2ND GEN\n", + "Match found in a589dcc642fdb10a/2021-06-14--20-54-26/2/s for VOLKSWAGEN TOURAN 2ND GEN\n", + "Match found in a589dcc642fdb10a/2021-06-14--20-54-26/1/s for VOLKSWAGEN TOURAN 2ND GEN\n", + "Match found in 207b9d7ee3fb513a/2023-12-19--14-59-25/14/s for VOLKSWAGEN TRANSPORTER T6.1\n", + "Match found in a459f4556782eba1/2023-11-05--17-16-20/22/s for VOLKSWAGEN TRANSPORTER T6.1\n", + "Match found in a459f4556782eba1/2023-11-27--12-27-58/47/s for VOLKSWAGEN TRANSPORTER T6.1\n", + "Match found in 0cd0b7f7e31a3853/2021-11-18--00-38-32/0/s for SKODA KODIAQ 1ST GEN\n", + "Match found in 0cd0b7f7e31a3853/2021-11-18--00-38-32/1/s for SKODA KODIAQ 1ST GEN\n", + "Match found in 0cd0b7f7e31a3853/2021-11-18--00-38-32/2/s for SKODA KODIAQ 1ST GEN\n", + "Match found in a973e9182bc96a2c/2024-01-14--15-14-33/54/s for AUDI A3 3RD GEN\n", + "Match found in 23daff6c438612d2/2023-12-21--15-37-32/22/s for AUDI A3 3RD GEN\n", + "Match found in 23daff6c438612d2/2024-01-17--09-31-14/20/s for AUDI A3 3RD GEN\n", + "Match found in 6c6b466346192818/2021-06-06--14-17-47/0/s for AUDI Q2 1ST GEN\n", + "Match found in 6c6b466346192818/2021-06-06--14-17-47/1/s for AUDI Q2 1ST GEN\n", + "Match found in 6c6b466346192818/2021-06-06--14-17-47/2/s for AUDI Q2 1ST GEN\n", + "Match found in 839125529d3c3cdf/2023-11-29--15-49-50/56/s for AUDI Q3 2ND GEN\n", + "Match found in d7bfab70d5011e1d/2023-11-24--00-49-14/24/s for AUDI Q3 2ND GEN\n", + "Match found in 98a3015c4f16846d/2023-11-04--12-32-32/76/s for AUDI Q3 2ND GEN\n", + "Match found in fc6b6c9a3471c846/2021-05-27--13-39-56/2/s for SEAT LEON 3RD GEN\n", + "Match found in fc6b6c9a3471c846/2021-05-27--13-39-56/1/s for SEAT LEON 3RD GEN\n", + "Match found in aef9c04d6ec5cd57/2023-07-15--16-49-38/12/s for SEAT LEON 3RD GEN\n", + "Match found in 0bbe367c98fa1538/2023-03-04--17-46-11/2/s for VOLKSWAGEN POLO 6TH GEN\n", + "Match found in 0bbe367c98fa1538/2023-03-04--17-46-11/1/s for VOLKSWAGEN POLO 6TH GEN\n", + "Match found in 0bbe367c98fa1538/2023-03-04--17-46-11/0/s for VOLKSWAGEN POLO 6TH GEN\n", + "Match found in 026b6d18fba6417f/2021-03-26--09-17-04/0/s for SKODA SCALA 1ST GEN\n", + "Match found in 026b6d18fba6417f/2021-03-26--09-17-04/1/s for SKODA SCALA 1ST GEN\n", + "Match found in 026b6d18fba6417f/2021-03-26--09-17-04/2/s for SKODA SCALA 1ST GEN\n", + "Match found in 12d6ae3057c04b0d/2021-09-04--21-21-21/1/s for SKODA KODIAQ 1ST GEN\n", + "Match found in 12d6ae3057c04b0d/2021-09-04--21-21-21/0/s for SKODA KODIAQ 1ST GEN\n", + "Match found in 7d76baac7cf42e15/2024-01-13--03-42-46/2/s for SKODA KAROQ 1ST GEN\n", + "Match found in 8a5da7c1d1783730/2024-01-17--06-32-18/4/s for SKODA KODIAQ 1ST GEN\n", + "Match found in 8a5da7c1d1783730/2023-12-23--16-48-07/42/s for SKODA KODIAQ 1ST GEN\n", + "Match found in 2ca49a03c8084514/2023-12-27--08-54-31/4/s for SKODA KODIAQ 1ST GEN\n", + "Match found in 66e5edc3a16459c5/2021-05-25--19-00-29/1/s for SKODA OCTAVIA 3RD GEN\n", + "Match found in f5392228324cda8d/2023-10-29--14-05-24/120/s for SKODA OCTAVIA 3RD GEN\n", + "Match found in 3fa7570f2fcace3d/2023-11-11--07-57-34/1/s for SKODA OCTAVIA 3RD GEN\n", + "Match found in 54ada937747ef8ca/2023-11-09--16-13-28/12/s for SKODA SUPERB 3RD GEN\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Match found in 54ada937747ef8ca/2023-12-14--08-14-41/8/s for SKODA SUPERB 3RD GEN\n", + "Match found in 54ada937747ef8ca/2023-11-16--06-01-05/7/s for SKODA SUPERB 3RD GEN\n", + "Analysis finished\n" + ] + } + ], + "source": [ + "from openpilot.selfdrive.pandad import can_capnp_to_list\n", + "from openpilot.tools.lib.logreader import LogReader\n", + "\n", + "message_to_check = 0x3c0 # Volkswagen CAN ignition message\n", + "\n", + "segment_count = len(TEST_SEGMENTS)\n", + "for idx, segment in enumerate(TEST_SEGMENTS):\n", + " lr = LogReader(segment)\n", + " CP = lr.first(\"carParams\")\n", + " if CP is None:\n", + " continue\n", + "\n", + " can_packets = [msg for msg in lr if msg.which() == \"can\"]\n", + "\n", + " # print(f\"Evaluating segment {idx} of {segment_count} for {CP.carFingerprint}\")\n", + "\n", + " matched_segments = {}\n", + " for packet in can_packets:\n", + " for msg in packet.can:\n", + " if msg.address == message_to_check:\n", + " matched_segments.update({segment: CP.carFingerprint})\n", + "\n", + " if segment in matched_segments:\n", + " print(f\"Match found in {segment} for {CP.carFingerprint}\")\n", + "\n", + "print(f\"Analysis finished\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7724dd97-f62e-4fd3-9f64-63d49be669d2", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9f393e00-8efd-40fb-a41e-d312531a83e8", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "openpilot", + "language": "python", + "name": "openpilot" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}