Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HKG: use platform codes to fuzzy fingerprint #28531

Merged
merged 238 commits into from Jun 15, 2023
Merged

HKG: use platform codes to fuzzy fingerprint #28531

merged 238 commits into from Jun 15, 2023

Conversation

sshane
Copy link
Contributor

@sshane sshane commented Jun 13, 2023

v2 of #26939

Uses combination of platform codes, part numbers, and ECU FW dates to fuzzy match. Think of it as a less-specific FW version. Should catch cases where a car uses a new part number we haven't seen (and requires different tuning), as well as new model years we don't support yet (with possible different architectures like the new Palisades).

  • first tries standard fuzzy fingerprinting, then if no matches tries hyundai fuzzy fingerprinting
  • invalidate all ICE and hybrid CAN FD platforms as they often do not have specifiers to tell the difference
    • can remove once we add hvac ECU which tells us this!
  • check date of FW version to prevent newer model years we haven't seen from fuzzy matching
  • check part number to catch cases like the Tucson using a Santa Cruz EPS

selfdrive/car/hyundai/values.py Outdated Show resolved Hide resolved
selfdrive/car/hyundai/values.py Outdated Show resolved Hide resolved
@sshane
Copy link
Contributor Author

sshane commented Jun 15, 2023

Checked 214 mock and likely Hyundai dongles (checking present ECUs) from routes from the last year which fuzzy matched only with the new function (checking for false positives), here are the results. Looks good! Parsed the available VINs:

(new fuzzy match, VIN platform)
('HYUNDAI IONIQ 5 2022', 'HYUNDAI IONIQ 5 2022 BEV (Battery Electric Vehicle)')
('HYUNDAI SANTA FE 2019', 'HYUNDAI Santa Fe 2019 ')
('HYUNDAI IONIQ 5 2022', 'HYUNDAI IONIQ 5 2022 BEV (Battery Electric Vehicle)')
('HYUNDAI IONIQ 5 2022', 'HYUNDAI  1993 ')
('KIA EV6 2022', '  1993 ')
('HYUNDAI ELANTRA 2021', 'HYUNDAI  1991 ')
('HYUNDAI IONIQ 5 2022', 'HYUNDAI  1993 ')
('KIA STINGER GT2 2018', 'KIA Stinger 2019 ')
('HYUNDAI SONATA 2020', 'HYUNDAI Sonata 2021 ')
('HYUNDAI SONATA 2020', 'HYUNDAI Sonata 2022 ')
('KIA NIRO EV 2ND GEN', 'KIA Niro 2023 BEV (Battery Electric Vehicle)')
('HYUNDAI IONIQ 5 2022', 'HYUNDAI  1992 ')
('KIA STINGER GT2 2018', 'KIA Stinger 2019 ')
('KIA EV6 2022', 'KIA EV6 2022 BEV (Battery Electric Vehicle)')
('KIA STINGER GT2 2018', 'KIA Stinger 2019 ')
('HYUNDAI ELANTRA HYBRID 2021', 'HYUNDAI Elantra 2023 HEV (Hybrid Electric Vehicle) - Level Unknown')
('HYUNDAI PALISADE 2020', 'HYUNDAI Palisade 2021 ')
('HYUNDAI IONIQ 5 2022', 'HYUNDAI IONIQ 5 2022 BEV (Battery Electric Vehicle)')
('HYUNDAI SANTA FE PlUG-IN HYBRID 2022', 'HYUNDAI Santa Fe 2022 PHEV (Plug-in Hybrid Electric Vehicle)')
('KIA K5 2021', 'KIA K5 2021 ')
('HYUNDAI IONIQ 5 2022', 'HYUNDAI  1992 ')
('HYUNDAI SONATA 2020', 'HYUNDAI Sonata 2022 ')
('KIA EV6 2022', 'KIA EV6 2023 BEV (Battery Electric Vehicle)')
('HYUNDAI ELANTRA HYBRID 2021', 'HYUNDAI Elantra 2023 HEV (Hybrid Electric Vehicle) - Level Unknown')
('HYUNDAI SANTA FE 2019', 'HYUNDAI Santa Fe 2020 ')
('HYUNDAI PALISADE 2020', 'KIA Telluride 2020 ')
('GENESIS G70 2020', 'GENESIS G70 2020 ')
('GENESIS G80 2017', 'GENESIS G80 2018 ')
('HYUNDAI IONIQ 5 2022', 'HYUNDAI IONIQ 5 2022 BEV (Battery Electric Vehicle)')
('KIA EV6 2022', '  1992 ')
('HYUNDAI IONIQ PLUG-IN HYBRID 2019', 'HYUNDAI Ioniq 2019 PHEV (Plug-in Hybrid Electric Vehicle)')
('HYUNDAI ELANTRA HYBRID 2021', 'HYUNDAI Elantra 2023 HEV (Hybrid Electric Vehicle) - Level Unknown')
('HYUNDAI IONIQ PHEV 2020', 'HYUNDAI  1990 ')
('HYUNDAI SANTA FE 2022', 'HYUNDAI Santa Fe 2022 ')
('HYUNDAI IONIQ 5 2022', 'HYUNDAI IONIQ 5 2022 BEV (Battery Electric Vehicle)')
('HYUNDAI IONIQ PHEV 2020', 'HYUNDAI Ioniq 2020 PHEV (Plug-in Hybrid Electric Vehicle)')
('GENESIS GV60 ELECTRIC 1ST GEN', 'GENESIS GV60 2023 BEV (Battery Electric Vehicle)')
('GENESIS GV60 ELECTRIC 1ST GEN', 'GENESIS GV60 2023 BEV (Battery Electric Vehicle)')
('HYUNDAI ELANTRA HYBRID 2021', 'HYUNDAI Elantra 2023 HEV (Hybrid Electric Vehicle) - Level Unknown')
('HYUNDAI IONIQ 5 2022', 'HYUNDAI  1993 ')
('KIA NIRO HYBRID 2019', 'KIA Niro 2019 PHEV (Plug-in Hybrid Electric Vehicle)')
('KIA STINGER 2022', '  1992 ')
('HYUNDAI SANTA FE 2022', 'HYUNDAI Santa Fe 2022 ')
('HYUNDAI ELANTRA HYBRID 2021', 'HYUNDAI Elantra 2023 HEV (Hybrid Electric Vehicle) - Level Unknown')
('HYUNDAI IONIQ 5 2022', 'HYUNDAI IONIQ 5 2022 BEV (Battery Electric Vehicle)')
('KIA EV6 2022', '  1992 ')
('GENESIS G70 2020', 'GENESIS G70 2021 ')
('HYUNDAI IONIQ PLUG-IN HYBRID 2019', 'HYUNDAI Ioniq 2019 PHEV (Plug-in Hybrid Electric Vehicle)')
('HYUNDAI SONATA 2020', 'HYUNDAI Sonata 2021 ')
('HYUNDAI SANTA FE 2019', 'HYUNDAI Santa Fe 2020 ')
('KIA STINGER GT2 2018', 'KIA Stinger 2019 ')
('HYUNDAI IONIQ PHEV 2020', 'HYUNDAI Ioniq 2020 PHEV (Plug-in Hybrid Electric Vehicle)')
('HYUNDAI SANTA FE 2022', 'HYUNDAI Santa Fe 2022 ')
('HYUNDAI SONATA 2020', 'HYUNDAI Sonata 2021 ')
('KIA K5 2021', 'KIA K5 2022 ')
('GENESIS G90 2017', 'GENESIS G90 2017 ')
('HYUNDAI PALISADE 2020', 'HYUNDAI Palisade 2022 ')
('HYUNDAI ELANTRA 2021', 'HYUNDAI Elantra 2022 ')
('HYUNDAI ELANTRA HYBRID 2021', 'HYUNDAI Elantra 2023 HEV (Hybrid Electric Vehicle) - Level Unknown')
('HYUNDAI SONATA 2020', 'HYUNDAI Sonata 2022 ')
('HYUNDAI IONIQ PHEV 2020', 'HYUNDAI Ioniq 2020 PHEV (Plug-in Hybrid Electric Vehicle)')
('KIA EV6 2022', '  1992 ')
('HYUNDAI IONIQ 5 2022', 'HYUNDAI  1992 ')
('HYUNDAI ELANTRA 2021', 'HYUNDAI Elantra 2021 ')
('HYUNDAI IONIQ 5 2022', 'HYUNDAI  1992 ')
('HYUNDAI TUCSON 2019', 'HYUNDAI  1989 ')
('HYUNDAI ELANTRA HYBRID 2021', 'HYUNDAI Elantra 2023 HEV (Hybrid Electric Vehicle) - Level Unknown')
('HYUNDAI IONIQ 5 2022', 'HYUNDAI IONIQ 5 2022 BEV (Battery Electric Vehicle)')
('HYUNDAI SONATA 2020', 'HYUNDAI Sonata 2022 ')
('HYUNDAI SANTA FE 2019', 'HYUNDAI Santa Fe 2020 ')
('HYUNDAI IONIQ PLUG-IN HYBRID 2019', 'HYUNDAI Ioniq 2019 PHEV (Plug-in Hybrid Electric Vehicle)')

@sshane
Copy link
Contributor Author

sshane commented Jun 15, 2023

Here are the results from the original fuzzy function vs new Hyundai-specific fuzzy function. The routes are self explanatory, the dongles are added into each category if any route from them ever fingerprinted as "mock", and if they ever matched with either function. Last year of data.

I also spot checked a few routes which didn't fuzzy fingerprint with the new function, and they had part numbers not in the database or dates slightly out of range (few months). This will improve in time as we combine platforms, and eventually can remove dates.

Routes:
Total mock (likely) Hyundai routes: 1720
Traditional fuzzy catches: 184
Hyundai fuzzy catches: 1016
Hyundai fuzzy didn't catch mock, old did: 16
Combined catches: 1032

Dongles:
Total mock (likely) Hyundai dongles: 193
Traditional fuzzy dongle catches: 27
Hyundai fuzzy dongle catches: 111
Hyundai fuzzy didn't catch mock, old did: 5
Hyundai fuzzy didn't catch mock, old did: {'KIA OPTIMA 4TH GEN FACELIFT', 'HYUNDAI ELANTRA 2017', 'KIA K5 2021', 'HYUNDAI ELANTRA 2021'}
Combined dongle catches: 116
How I got the results (this is ran in the loop below):
  ...
  if platform == "mock" and fuzzy_brand == "hyundai":
    total_mock_routes += 1
    total_mock_dongles.add(dongle)

    # code to add to dongle_to_vin_platform...

    if match is not None and match_hyundai is None:
      new_function_didnt_catch_mock += 1
      new_function_didnt_catch_mock_dongles.add(dongle)
      new_function_didnt_catch_mock_platforms.add(match)

    if match is not None:
      old_match_catches_mock += 1
      old_match_catches_mock_dongles.add(dongle)
      old_match_catches_mock_platforms.add(match)

    if match_hyundai is not None:
      new_match_catches_mock += 1
      new_match_catches_mock_dongles.add(dongle)
      new_match_catches_mock_platforms.add(match_hyundai)
    
    if match is not None or match_hyundai is not None:
      combined_match_catches_mock += 1
      combined_match_catches_mock_dongles.add(dongle)
      combined_match_catches_mock_platforms.add(match or match_hyundai)
      
    match_info.append((platform, match, match_hyundai, dongle_to_vin_platform[dongle], segment))

@sshane
Copy link
Contributor Author

sshane commented Jun 15, 2023

I also ran these sanity checks on the last year's worth of routes:

for r in tqdm(pool_ret):
  segment, fingerprint_msg, CP, platform, matches, matches_hyundai = r
  dongle = segment.split('|')[0]
  
  # get what we would match (len of matches == 1)
  match = list(matches)[0] if len(matches) == 1 else None
  match_hyundai = list(matches_hyundai)[0] if len(matches_hyundai) == 1 else None

  # Returns likely brand for mock platforms based on present ECUs
  fuzzy_brand = get_most_likely_brand(CP)

  # check we don't match to set of platforms we expect not to
  # these are all Genesis G80 with rare unique part numbers, this is ok
  if match_hyundai in CANT_FUZZY_FP_PLATFORMS and dongle not in ("bd880d272b2188ff", "e20ec117fa6a8c81", "035dff468a60ed06", "b8f31ec96ab82e13"):
    print('fingerprinted with bad platform', platform, matches, matches_hyundai, segment)

  # check that match from traditional fuzzy and hyundai fuzzy don't disagree
  # no disagreements, great
  if match is not None and match_hyundai is not None:
    if match != match_hyundai:
      print('fuzzy funcs disagree on match', platform, match, match_hyundai, segment)

@sshane
Copy link
Contributor Author

sshane commented Jun 15, 2023

Total data checked:

Total platforms: 53
Total dongles: 613
Total routes: 50105

Total mock platforms: 27
Total mock dongles: 193
Total mock routes: 1720

@sshane sshane merged commit f788edb into master Jun 15, 2023
36 of 37 checks passed
@sshane sshane deleted the hkz-fuzzy-2 branch June 15, 2023 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants