Update mapd to v2

This commit is contained in:
James
2026-01-06 17:12:51 -07:00
parent dc9a91e201
commit 5758e61a6d
17 changed files with 281 additions and 322 deletions
+52 -12
View File
@@ -9,6 +9,7 @@ import time
from pathlib import Path
from cereal import messaging
from openpilot.common.basedir import BASEDIR
from openpilot.common.params import Params
from openpilot.common.time_helpers import system_time_valid
@@ -19,7 +20,7 @@ from openpilot.frogpilot.assets.theme_manager import ThemeManager
from openpilot.frogpilot.common.frogpilot_backups import backup_frogpilot
from openpilot.frogpilot.common.frogpilot_utilities import is_FrogsGoMoo, run_cmd, use_konik_server
from openpilot.frogpilot.common.frogpilot_variables import (
DISCORD_WEBHOOK_URL_REPORT, ERROR_LOGS_PATH, FROGS_GO_MOO_PATH, HD_LOGS_PATH, KONIK_LOGS_PATH, MAPD_PATH, MAPS_PATH, THEME_SAVE_PATH,
DISCORD_WEBHOOK_URL_REPORT, ERROR_LOGS_PATH, FROGS_GO_MOO_PATH, HD_LOGS_PATH, KONIK_LOGS_PATH, MAPS_PATH, THEME_SAVE_PATH,
FrogPilotVariables, get_frogpilot_toggles
)
@@ -66,6 +67,21 @@ def capture_report(discord_user, report, frogpilot_toggles):
def frogpilot_boot_functions(build_metadata, params):
params_memory = Params(memory=True)
maps_selected = params.get("MapsSelected")
if maps_selected:
try:
data = json.loads(maps_selected)
if isinstance(data, dict):
new_items = []
for nation in data.get("nations", []):
new_items.append(f"nation.{nation}")
for state in data.get("states", []):
new_items.append(f"us_state.{state}")
new_items.sort()
params.put("MapsSelected", ",".join(new_items))
except (json.JSONDecodeError, TypeError, ValueError):
pass
FrogPilotVariables()
ThemeManager(params, params_memory, boot_run=True).update_active_theme(time_validated=system_time_valid(), frogpilot_toggles=get_frogpilot_toggles(), boot_run=True)
@@ -138,12 +154,9 @@ def update_boot_logo(frogpilot=False, stock=False):
run_cmd(["sudo", "mount", "-o", f"remount,{mount_options}", "/"], "Successfully restored / mount options", "Failed to restore / mount options")
def update_maps(now, params, params_memory):
while not MAPD_PATH.exists():
time.sleep(60)
def update_maps(now, params, params_memory, manual_update=False):
maps_selected = params.get("MapsSelected")
if not maps_selected or not (maps_selected.get("nations") or maps_selected.get("states")):
if not maps_selected:
return
day = now.day
@@ -152,22 +165,49 @@ def update_maps(now, params, params_memory):
schedule = params.get("PreferredSchedule")
maps_downloaded = MAPS_PATH.exists()
if maps_downloaded and (schedule == 0 or (schedule == 1 and not is_sunday) or (schedule == 2 and not is_first)):
if maps_downloaded and (schedule == 0 or (schedule == 1 and not is_sunday) or (schedule == 2 and not is_first)) and not manual_update:
return
suffix = "th" if 11 <= day <= 13 else {1: "st", 2: "nd", 3: "rd"}.get(day % 10, "th")
todays_date = now.strftime(f"%B {day}{suffix}, %Y")
if maps_downloaded and params.get("LastMapsUpdate") == todays_date:
if maps_downloaded and params.get("LastMapsUpdate") == todays_date and not manual_update:
return
if params.get("OSMDownloadProgress") is None:
params_memory.put("OSMDownloadLocations", maps_selected)
pm = messaging.PubMaster(["mapdIn"])
sm = messaging.SubMaster(["mapdExtendedOut"])
while params.get("OSMDownloadProgress") is not None:
time.sleep(60)
time.sleep(1)
msg = messaging.new_message("mapdIn")
msg.mapdIn.type = 0
msg.mapdIn.str = maps_selected
pm.send("mapdIn", msg)
started = False
while True:
sm.update(1000)
if params_memory.get_bool("CancelDownloadMaps"):
msg = messaging.new_message("mapdIn")
msg.mapdIn.type = 27
pm.send("mapdIn", msg)
params_memory.remove("CancelDownloadMaps")
params_memory.remove("DownloadMaps")
return
if sm.updated["mapdExtendedOut"]:
progress = sm["mapdExtendedOut"].downloadProgress
if progress.active:
started = True
if not progress.active and started:
break
params.put("LastMapsUpdate", todays_date)
params_memory.remove("DownloadMaps")
def update_openpilot(thread_manager, params):
-1
View File
@@ -71,7 +71,6 @@ HD_PATH = Path("/cache/use_HD")
KONIK_LOGS_PATH = Path("/data/media/0/realdata_konik")
KONIK_PATH = Path("/cache/use_konik")
MAPD_PATH = Path("/data/media/0/osm/mapd")
MAPS_PATH = Path("/data/media/0/osm/offline")
NNFF_MODELS_PATH = Path(BASEDIR) / "frogpilot/assets/nnff_models"