This commit is contained in:
Your Name
2024-04-28 13:21:06 -05:00
parent 784daf270a
commit dd6ead0477
11 changed files with 150 additions and 32 deletions

View File

@@ -6,12 +6,14 @@ import urllib.request
from openpilot.common.params import Params
from openpilot.system.version import get_short_branch
# CLEARPILOT this doesnt really matter.
VERSION = 'v1' if get_short_branch() == "clearpilot" else 'v2'
REPOSITORY_URL = 'https://privategit.hanson.xyz/brianhansonxyz/clearpilot'
DEFAULT_MODEL = "wd-40"
DEFAULT_MODEL_NAME = "WD40 (Default)"
MODELS_PATH = '/data/models'
# CLEARPILOT changed path.
MODELS_PATH = '/data/openpilot/selfdrive/clearpilot/models'
NAVIGATIONLESS_MODELS = {"radical-turtle", "wd-40"}
RADARLESS_MODELS = {"radical-turtle"}
@@ -77,26 +79,24 @@ def download_model():
print(f"Failed to download the {model} model after {attempt + 1} attempts. Giving up... :(")
def populate_models():
model_names_url = f"https://raw.githubusercontent.com/FrogAi/FrogPilot-Resources/master/model_names_{VERSION}.txt"
# CLEARPILOT hardcoded list
models = """
wd-40 - WD40 (Default)
duck-amigo - Duck Amigo
"""
# todo - get farmville working
# farmville - FarmVille
for attempt in range(5):
try:
with urllib.request.urlopen(model_names_url) as response:
model_info = [line.decode('utf-8').strip().split(' - ') for line in response.readlines() if ' - ' in line.decode('utf-8')]
model_info = [line.decode('utf-8').strip().split(' - ') for line in models.readlines() if ' - ' in line.decode('utf-8')]
available_models = ','.join(model[0] for model in model_info)
available_models_names = [model[1] for model in model_info]
available_models = ','.join(model[0] for model in model_info)
available_models_names = [model[1] for model in model_info]
params.put("AvailableModels", available_models)
params.put("AvailableModelsNames", ','.join(available_models_names))
params.put("AvailableModels", available_models)
params.put("AvailableModelsNames", ','.join(available_models_names))
current_model_name = params.get("ModelName", encoding='utf-8')
if current_model_name not in available_models_names and "(Default)" in current_model_name:
updated_model_name = current_model_name.replace("(Default)", "").strip()
params.put("ModelName", updated_model_name)
current_model_name = params.get("ModelName", encoding='utf-8')
if current_model_name not in available_models_names and "(Default)" in current_model_name:
updated_model_name = current_model_name.replace("(Default)", "").strip()
params.put("ModelName", updated_model_name)
except Exception as e:
print(f"Failed to update models list. Error: {e}. Retrying...")
time.sleep(5)
else:
print(f"Failed to update models list after 5 attempts. Giving up... :(")