mapd: bump version and fix missing folder (#994)

* fix mapd folder

* not needed

* unnecessary

* Remove unused import from mapd_installer.py

Deleted the unused import of Paths from openpilot.system.hardware.hw to clean up the code.

* Undo changes

* update: adjust `mapd` process to conditionally start based on readiness

- Added `mapd_ready` function to check `mapd` readiness.
- Modified `mapd` process to use this readiness condition.

* update: bump mapd version to v1.10.0 and add readiness utility

- Updated `VERSION` to v1.10.0 for `mapd_installer.py`.

* update: integrate `MapdInstallManager` versioning into main thread

- Added a call to `MapdInstallManager.update_installed_version` with `VERSION`.
- Ensures version management for `mapd` is synchronized during runtime.

* refactor: centralize `MAPD_PATH` and `MAPD_BIN_DIR` definitions in module init

- Moved constants to `sunnypilot/mapd/__init__.py` for cleaner imports and reuse.
- Updated references in `mapd_manager.py` and `mapd_installer.py`.

* revert back the file permission

* do this

* no longer static

---------

Co-authored-by: DevTekVE <devtekve@gmail.com>
Co-authored-by: rav4kumar <meetkumardesai@gmail.com>
Co-authored-by: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com>
Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
This commit is contained in:
royjr
2025-07-25 11:25:31 -04:00
committed by GitHub
parent 358c0a8747
commit 0a2e8dd81b
5 changed files with 29 additions and 20 deletions
+5
View File
@@ -0,0 +1,5 @@
import os
from openpilot.common.basedir import BASEDIR
MAPD_BIN_DIR = os.path.join(BASEDIR, 'third_party/mapd_pfeiferj')
MAPD_PATH = os.path.join(MAPD_BIN_DIR, 'mapd')
+17 -15
View File
@@ -16,32 +16,39 @@ from urllib.request import urlopen
from cereal import messaging
from openpilot.common.params import Params
from openpilot.sunnypilot.mapd.mapd_manager import MAPD_PATH, MAPD_BIN_DIR
from openpilot.system.hardware.hw import Paths
from openpilot.common.spinner import Spinner
from openpilot.system.version import is_prebuilt
from openpilot.sunnypilot.mapd import MAPD_PATH, MAPD_BIN_DIR
import openpilot.system.sentry as sentry
VERSION = 'v1.9.0'
VERSION = 'v1.10.0'
URL = f"https://github.com/pfeiferj/openpilot-mapd/releases/download/{VERSION}/mapd"
def update_installed_version(version: str, params: Params = None) -> None:
if params is None:
params = Params()
params.put("MapdVersion", version)
class MapdInstallManager:
def __init__(self, spinner_ref: Spinner):
self._spinner = spinner_ref
self._params = Params()
def download(self) -> None:
self.ensure_directories_exist()
self._download_file()
self.update_installed_version(VERSION)
update_installed_version(VERSION, self._params)
def check_and_download(self) -> None:
if self.download_needed():
self.download()
@staticmethod
def download_needed() -> bool:
return not os.path.exists(MAPD_PATH) or MapdInstallManager.get_installed_version() != VERSION
def download_needed(self) -> bool:
return not os.path.exists(MAPD_PATH) or self.get_installed_version() != VERSION
@staticmethod
def ensure_directories_exist() -> None:
@@ -82,13 +89,8 @@ class MapdInstallManager:
temp_file.unlink()
logging.error("Failed to download file after all retries")
@staticmethod
def update_installed_version(version: str) -> None:
Params().put("MapdVersion", version)
@staticmethod
def get_installed_version() -> str:
return Params().get("MapdVersion", encoding="utf-8") or ""
def get_installed_version(self) -> str:
return self._params.get("MapdVersion", encoding="utf-8") or ""
def wait_for_internet_connection(self, return_on_failure: bool = False) -> bool:
max_retries = 10
@@ -122,7 +124,7 @@ class MapdInstallManager:
return
if self.wait_for_internet_connection(return_on_failure=True):
self._spinner.update(f"Downloading pfeiferj's mapd [{install_manager.get_installed_version()}] => [{VERSION}].")
self._spinner.update(f"Downloading pfeiferj's mapd [{self.get_installed_version()}] => [{VERSION}].")
time.sleep(0.1)
self.check_and_download()
self._spinner.close()
@@ -146,7 +148,7 @@ if __name__ == "__main__":
if is_prebuilt():
debug_msg = f"[DEBUG] This is prebuilt, no mapd install required. VERSION: [{VERSION}], Param [{install_manager.get_installed_version()}]"
spinner.update(debug_msg)
install_manager.update_installed_version(VERSION)
update_installed_version(VERSION)
else:
spinner.update(f"Checking if mapd is installed and valid. Prebuilt [{is_prebuilt()}]")
install_manager.non_prebuilt_install()
+3 -4
View File
@@ -12,22 +12,20 @@ import os
import glob
import shutil
from openpilot.common.basedir import BASEDIR
from openpilot.common.params import Params
from openpilot.common.realtime import Ratekeeper, config_realtime_process
from openpilot.common.swaglog import cloudlog
from openpilot.selfdrive.selfdrived.alertmanager import set_offroad_alert
from openpilot.sunnypilot.mapd.live_map_data.osm_map_data import OsmMapData
from openpilot.system.hardware.hw import Paths
from openpilot.sunnypilot.mapd import MAPD_PATH
from openpilot.sunnypilot.mapd.mapd_installer import VERSION, update_installed_version
# PFEIFER - MAPD {{
params = Params()
mem_params = Params("/dev/shm/params") if platform.system() != "Darwin" else params
# }} PFEIFER - MAPD
MAPD_BIN_DIR = os.path.join(BASEDIR, 'third_party/mapd_pfeiferj')
MAPD_PATH = os.path.join(MAPD_BIN_DIR, 'mapd')
def get_files_for_cleanup() -> list[str]:
paths = [
@@ -117,6 +115,7 @@ def update_osm_db() -> None:
def main_thread():
update_installed_version(VERSION, params)
config_realtime_process([0, 1, 2, 3], 5)
rk = Ratekeeper(1, print_delay_threshold=None)
+4 -1
View File
@@ -88,6 +88,9 @@ def is_stock_model(started, params, CP: car.CarParams) -> bool:
"""Check if the active model runner is stock."""
return bool(get_active_model_runner(params, not started) == custom.ModelManagerSP.Runner.stock)
def mapd_ready(started: bool, params: Params, CP: car.CarParams) -> bool:
return bool(os.path.exists(Paths.mapd_root()))
def or_(*fns):
return lambda *args: operator.or_(*(fn(*args) for fn in fns))
@@ -162,7 +165,7 @@ procs += [
PythonProcess("backup_manager", "sunnypilot.sunnylink.backups.manager", and_(only_offroad, sunnylink_ready_shim)),
# mapd
NativeProcess("mapd", Paths.mapd_root(), [MAPD_PATH], always_run),
NativeProcess("mapd", Paths.mapd_root(), [MAPD_PATH], mapd_ready),
PythonProcess("mapd_manager", "sunnypilot.mapd.mapd_manager", always_run),
]
BIN
View File
Binary file not shown.