diff --git a/selfdrive/manager/manager.py b/selfdrive/manager/manager.py index 13eac7f59a..96accf0368 100755 --- a/selfdrive/manager/manager.py +++ b/selfdrive/manager/manager.py @@ -17,6 +17,7 @@ from openpilot.selfdrive.manager.process import ensure_running from openpilot.selfdrive.manager.process_config import managed_processes from openpilot.selfdrive.athena.registration import register, UNREGISTERED_DONGLE_ID, is_registered_device from openpilot.common.swaglog import cloudlog, add_file_handler +from openpilot.system.hardware.hw import Paths from openpilot.system.version import get_build_metadata, terms_version, training_version @@ -179,7 +180,7 @@ def manager_init() -> None: if os.path.isfile(os.path.join(sentry.CRASHES_DIR, 'error.txt')): os.remove(os.path.join(sentry.CRASHES_DIR, 'error.txt')) - models_dir = "/data/media/0/models" + models_dir = Paths.model_root() if not os.path.exists(models_dir): os.makedirs(models_dir) diff --git a/selfdrive/manager/process_config.py b/selfdrive/manager/process_config.py index 79c16e70ff..de84a43f16 100644 --- a/selfdrive/manager/process_config.py +++ b/selfdrive/manager/process_config.py @@ -91,12 +91,12 @@ procs = [ NativeProcess("ui", "selfdrive/ui", ["./ui"], always_run, watchdog_max_dt=(5 if not PC else None), always_watchdog=True), # PFEIFER - MAPD {{ - NativeProcess("mapd", COMMON_DIR, [MAPD_PATH], always_run), - PythonProcess("mapd_manager", "selfdrive.mapd_manager", always_run), + NativeProcess("mapd", COMMON_DIR, [MAPD_PATH], always_run, enabled=not PC), + PythonProcess("mapd_manager", "selfdrive.mapd_manager", always_run, enabled=not PC), # }} PFEIFER - MAPD PythonProcess("otisserv", "selfdrive.navd.otisserv", always_run), - PythonProcess("fleet_manager", "system.fleetmanager.fleet_manager", always_run), + PythonProcess("fleet_manager", "system.fleetmanager.fleet_manager", always_run, enabled=not PC), # debug procs NativeProcess("bridge", "cereal/messaging", ["./bridge"], notcar), diff --git a/selfdrive/mapd_manager.py b/selfdrive/mapd_manager.py index 8bc1bcccf6..3f389de6f8 100644 --- a/selfdrive/mapd_manager.py +++ b/selfdrive/mapd_manager.py @@ -4,12 +4,14 @@ import platform import numpy as np +from openpilot.common.basedir import BASEDIR from openpilot.common.params_pyx import Params from openpilot.selfdrive.controls.lib.alertmanager import set_offroad_alert from openpilot.selfdrive.navd.helpers import Coordinate from openpilot.selfdrive.sunnypilot.live_map_data import QUERY_RADIUS from openpilot.common.realtime import Ratekeeper, set_core_affinity from openpilot.common.swaglog import cloudlog +from openpilot.system.hardware.hw import Paths import os import glob import shutil @@ -22,8 +24,8 @@ params = Params() mem_params = Params("/dev/shm/params") if platform.system() != "Darwin" else params # }} PFEIFER - MAPD -COMMON_DIR = '/data/media/0/osm' -MAPD_BIN_DIR = '/data/openpilot/third_party/pfeiferj-mapd' +COMMON_DIR = Paths.mapd_root() +MAPD_BIN_DIR = os.path.join(BASEDIR, 'third_party/pfeiferj-mapd') MAPD_PATH = os.path.join(MAPD_BIN_DIR, 'mapd') diff --git a/selfdrive/modeld/modeld.py b/selfdrive/modeld/modeld.py index 2b8d05984e..48644fb675 100755 --- a/selfdrive/modeld/modeld.py +++ b/selfdrive/modeld/modeld.py @@ -27,6 +27,7 @@ from openpilot.selfdrive.modeld.fill_model_msg import fill_model_msg, fill_pose_ from openpilot.selfdrive.modeld.constants import ModelConstants from openpilot.selfdrive.modeld.models.commonmodel_pyx import ModelFrame, CLContext from openpilot.selfdrive.sunnypilot import get_model_generation +from openpilot.system.hardware.hw import Paths PROCESS_NAME = "selfdrive.modeld.modeld" SEND_RAW_PRED = os.getenv('SEND_RAW_PRED') @@ -37,7 +38,7 @@ MODEL_PATHS = { METADATA_PATH = Path(__file__).parent / 'models/supercombo_metadata.pkl' -CUSTOM_MODEL_PATH = "/data/media/0/models" +CUSTOM_MODEL_PATH = Paths.model_root() LaneChangeState = log.LaneChangeState diff --git a/selfdrive/modeld/navmodeld.py b/selfdrive/modeld/navmodeld.py index 29d07b36f7..50241b93ad 100755 --- a/selfdrive/modeld/navmodeld.py +++ b/selfdrive/modeld/navmodeld.py @@ -15,6 +15,7 @@ from openpilot.common.realtime import set_realtime_priority from openpilot.selfdrive.modeld.constants import ModelConstants from openpilot.selfdrive.modeld.runners import ModelRunner, Runtime from openpilot.selfdrive.sunnypilot import get_model_generation +from openpilot.system.hardware.hw import Paths NAV_INPUT_SIZE = 256*256 NAV_FEATURE_LEN = 256 @@ -22,7 +23,7 @@ NAV_DESIRE_LEN = 32 NAV_OUTPUT_SIZE = 2*2*ModelConstants.IDX_N + NAV_DESIRE_LEN + NAV_FEATURE_LEN MODEL_PATHS = {} -CUSTOM_MODEL_PATH = "/data/media/0/models" +CUSTOM_MODEL_PATH = Paths.model_root() class NavModelOutputXY(ctypes.Structure): _fields_ = [ diff --git a/selfdrive/sentry.py b/selfdrive/sentry.py index 09bd4748ab..8e30edf681 100644 --- a/selfdrive/sentry.py +++ b/selfdrive/sentry.py @@ -24,7 +24,7 @@ class SentryProject(Enum): SELFDRIVE_NATIVE = "https://7e3be9bfcfe04c9abe58bd25fe290d1a@o1138119.ingest.sentry.io/6191481" -CRASHES_DIR = '/data/community/crashes/' +CRASHES_DIR = Paths.community_crash_root() IP_ADDRESS = "{{auto}}" diff --git a/selfdrive/sunnypilot/__init__.py b/selfdrive/sunnypilot/__init__.py index 7c612d4004..96b5462601 100644 --- a/selfdrive/sunnypilot/__init__.py +++ b/selfdrive/sunnypilot/__init__.py @@ -1,4 +1,10 @@ +import os + + +SIMULATION = "SIMULATION" in os.environ + + def get_model_generation(params): - custom_model = params.get_bool("CustomDrivingModel") + custom_model = params.get_bool("CustomDrivingModel") and not SIMULATION gen = int(params.get("DrivingModelGeneration", encoding="utf8")) return custom_model, gen diff --git a/system/hardware/hw.py b/system/hardware/hw.py index 694299d72e..0069b2065e 100644 --- a/system/hardware/hw.py +++ b/system/hardware/hw.py @@ -56,3 +56,24 @@ class Paths: return Paths.comma_home() else: return "/tmp/.comma" + + @staticmethod + def community_crash_root() -> str: + if PC: + return str(Path(Paths.comma_home()) / "community" / "crashes") + else: + return "/data/community/crashes" + + @staticmethod + def model_root() -> str: + if PC: + return str(Path(Paths.comma_home()) / "media" / "0" / "models") + else: + return "/data/media/0/models" + + @staticmethod + def mapd_root() -> str: + if PC: + return str(Path(Paths.comma_home()) / "media" / "0" / "osm") + else: + return "/data/media/0/osm"