2021-03-07 22:02:08 -08:00
|
|
|
import os
|
2024-09-23 20:47:28 -07:00
|
|
|
import operator
|
2025-06-05 20:23:27 +03:00
|
|
|
import platform
|
2021-03-07 22:02:08 -08:00
|
|
|
|
2022-05-03 23:30:35 -07:00
|
|
|
from cereal import car
|
2023-08-20 20:49:55 -07:00
|
|
|
from openpilot.common.params import Params
|
|
|
|
|
from openpilot.system.hardware import PC, TICI
|
2024-05-25 12:41:17 -07:00
|
|
|
from openpilot.system.manager.process import PythonProcess, NativeProcess, DaemonProcess
|
2021-03-05 11:03:23 +01:00
|
|
|
|
2021-06-05 12:20:02 +08:00
|
|
|
WEBCAM = os.getenv("USE_WEBCAM") is not None
|
2021-03-07 22:02:08 -08:00
|
|
|
|
2022-05-03 23:30:35 -07:00
|
|
|
def driverview(started: bool, params: Params, CP: car.CarParams) -> bool:
|
2023-08-24 06:00:55 -07:00
|
|
|
return started or params.get_bool("IsDriverViewEnabled")
|
2022-05-03 23:30:35 -07:00
|
|
|
|
|
|
|
|
def notcar(started: bool, params: Params, CP: car.CarParams) -> bool:
|
2023-08-24 06:00:55 -07:00
|
|
|
return started and CP.notCar
|
2022-05-03 23:30:35 -07:00
|
|
|
|
2023-08-11 15:34:25 -07:00
|
|
|
def iscar(started: bool, params: Params, CP: car.CarParams) -> bool:
|
2023-08-24 06:00:55 -07:00
|
|
|
return started and not CP.notCar
|
2023-08-11 15:34:25 -07:00
|
|
|
|
2024-10-14 09:35:35 -07:00
|
|
|
def logging(started: bool, params: Params, CP: car.CarParams) -> bool:
|
2022-05-04 14:57:39 -07:00
|
|
|
run = (not CP.notCar) or not params.get_bool("DisableLogging")
|
2022-05-03 23:46:59 -07:00
|
|
|
return started and run
|
2022-05-03 23:30:35 -07:00
|
|
|
|
2023-03-14 13:31:49 -07:00
|
|
|
def ublox_available() -> bool:
|
|
|
|
|
return os.path.exists('/dev/ttyHS0') and not os.path.exists('/persist/comma/use-quectel-gps')
|
|
|
|
|
|
2024-10-14 09:35:35 -07:00
|
|
|
def ublox(started: bool, params: Params, CP: car.CarParams) -> bool:
|
2023-03-14 13:31:49 -07:00
|
|
|
use_ublox = ublox_available()
|
2023-06-29 16:05:00 -07:00
|
|
|
if use_ublox != params.get_bool("UbloxAvailable"):
|
|
|
|
|
params.put_bool("UbloxAvailable", use_ublox)
|
2023-01-14 23:06:09 -08:00
|
|
|
return started and use_ublox
|
|
|
|
|
|
2024-10-14 09:35:35 -07:00
|
|
|
def joystick(started: bool, params: Params, CP: car.CarParams) -> bool:
|
2024-09-07 17:03:22 -07:00
|
|
|
return started and params.get_bool("JoystickDebugMode")
|
|
|
|
|
|
2024-10-14 09:35:35 -07:00
|
|
|
def not_joystick(started: bool, params: Params, CP: car.CarParams) -> bool:
|
2024-09-07 17:03:22 -07:00
|
|
|
return started and not params.get_bool("JoystickDebugMode")
|
|
|
|
|
|
2024-10-14 09:35:35 -07:00
|
|
|
def long_maneuver(started: bool, params: Params, CP: car.CarParams) -> bool:
|
2024-09-12 14:10:18 -07:00
|
|
|
return started and params.get_bool("LongitudinalManeuverMode")
|
|
|
|
|
|
2024-10-14 09:35:35 -07:00
|
|
|
def not_long_maneuver(started: bool, params: Params, CP: car.CarParams) -> bool:
|
2024-09-12 14:10:18 -07:00
|
|
|
return started and not params.get_bool("LongitudinalManeuverMode")
|
|
|
|
|
|
2024-10-14 09:35:35 -07:00
|
|
|
def qcomgps(started: bool, params: Params, CP: car.CarParams) -> bool:
|
2023-03-14 13:31:49 -07:00
|
|
|
return started and not ublox_available()
|
|
|
|
|
|
2024-10-14 09:35:35 -07:00
|
|
|
def always_run(started: bool, params: Params, CP: car.CarParams) -> bool:
|
2023-08-24 06:00:55 -07:00
|
|
|
return True
|
|
|
|
|
|
2024-10-14 09:35:35 -07:00
|
|
|
def only_onroad(started: bool, params: Params, CP: car.CarParams) -> bool:
|
2023-08-24 06:00:55 -07:00
|
|
|
return started
|
|
|
|
|
|
2024-10-14 09:35:35 -07:00
|
|
|
def only_offroad(started: bool, params: Params, CP: car.CarParams) -> bool:
|
2023-08-24 06:00:55 -07:00
|
|
|
return not started
|
2022-06-11 23:19:27 -07:00
|
|
|
|
2024-09-23 20:47:28 -07:00
|
|
|
def or_(*fns):
|
|
|
|
|
return lambda *args: operator.or_(*(fn(*args) for fn in fns))
|
|
|
|
|
|
|
|
|
|
def and_(*fns):
|
|
|
|
|
return lambda *args: operator.and_(*(fn(*args) for fn in fns))
|
|
|
|
|
|
2023-08-24 06:00:55 -07:00
|
|
|
procs = [
|
2024-05-20 14:59:43 -07:00
|
|
|
DaemonProcess("manage_athenad", "system.athena.manage_athenad", "AthenadPid"),
|
2023-08-24 06:00:55 -07:00
|
|
|
|
2025-02-20 16:53:07 -08:00
|
|
|
NativeProcess("loggerd", "system/loggerd", ["./loggerd"], logging),
|
|
|
|
|
NativeProcess("encoderd", "system/loggerd", ["./encoderd"], only_onroad),
|
|
|
|
|
NativeProcess("stream_encoderd", "system/loggerd", ["./encoderd", "--stream"], notcar),
|
|
|
|
|
PythonProcess("logmessaged", "system.logmessaged", always_run),
|
|
|
|
|
|
2024-12-19 17:36:36 -05:00
|
|
|
NativeProcess("camerad", "system/camerad", ["./camerad"], driverview, enabled=not WEBCAM),
|
|
|
|
|
PythonProcess("webcamerad", "tools.webcam.camerad", driverview, enabled=WEBCAM),
|
2025-06-05 20:23:27 +03:00
|
|
|
NativeProcess("logcatd", "system/logcatd", ["./logcatd"], only_onroad, platform.system() != "Darwin"),
|
|
|
|
|
NativeProcess("proclogd", "system/proclogd", ["./proclogd"], only_onroad, platform.system() != "Darwin"),
|
2023-08-24 06:00:55 -07:00
|
|
|
PythonProcess("micd", "system.micd", iscar),
|
2024-01-22 18:35:11 -08:00
|
|
|
PythonProcess("timed", "system.timed", always_run, enabled=not PC),
|
2023-08-24 06:00:55 -07:00
|
|
|
|
2025-03-15 15:55:29 -07:00
|
|
|
PythonProcess("modeld", "selfdrive.modeld.modeld", only_onroad),
|
|
|
|
|
PythonProcess("dmonitoringmodeld", "selfdrive.modeld.dmonitoringmodeld", driverview, enabled=(WEBCAM or not PC)),
|
2025-03-02 13:39:36 -08:00
|
|
|
|
2025-05-30 13:31:07 -07:00
|
|
|
PythonProcess("sensord", "system.sensord.sensord", only_onroad, enabled=not PC),
|
2023-08-24 06:00:55 -07:00
|
|
|
NativeProcess("ui", "selfdrive/ui", ["./ui"], always_run, watchdog_max_dt=(5 if not PC else None)),
|
2023-12-05 18:10:01 -08:00
|
|
|
PythonProcess("soundd", "selfdrive.ui.soundd", only_onroad),
|
2024-09-04 02:54:57 -07:00
|
|
|
PythonProcess("locationd", "selfdrive.locationd.locationd", only_onroad),
|
2025-01-21 17:29:56 -08:00
|
|
|
NativeProcess("_pandad", "selfdrive/pandad", ["./pandad"], always_run, enabled=False),
|
2023-08-24 06:00:55 -07:00
|
|
|
PythonProcess("calibrationd", "selfdrive.locationd.calibrationd", only_onroad),
|
|
|
|
|
PythonProcess("torqued", "selfdrive.locationd.torqued", only_onroad),
|
2024-09-23 20:47:28 -07:00
|
|
|
PythonProcess("controlsd", "selfdrive.controls.controlsd", and_(not_joystick, iscar)),
|
|
|
|
|
PythonProcess("joystickd", "tools.joystick.joystickd", or_(joystick, notcar)),
|
2024-09-06 17:16:32 -07:00
|
|
|
PythonProcess("selfdrived", "selfdrive.selfdrived.selfdrived", only_onroad),
|
2024-05-21 03:18:10 -05:00
|
|
|
PythonProcess("card", "selfdrive.car.card", only_onroad),
|
2023-08-24 06:00:55 -07:00
|
|
|
PythonProcess("deleter", "system.loggerd.deleter", always_run),
|
2024-12-19 17:36:36 -05:00
|
|
|
PythonProcess("dmonitoringd", "selfdrive.monitoring.dmonitoringd", driverview, enabled=(WEBCAM or not PC)),
|
2023-11-18 23:23:16 -08:00
|
|
|
PythonProcess("qcomgpsd", "system.qcomgpsd.qcomgpsd", qcomgps, enabled=TICI),
|
2024-06-04 19:16:55 -07:00
|
|
|
PythonProcess("pandad", "selfdrive.pandad.pandad", always_run),
|
2023-08-24 06:00:55 -07:00
|
|
|
PythonProcess("paramsd", "selfdrive.locationd.paramsd", only_onroad),
|
2025-04-09 15:31:07 -07:00
|
|
|
PythonProcess("lagd", "selfdrive.locationd.lagd", only_onroad),
|
2023-08-24 06:00:55 -07:00
|
|
|
NativeProcess("ubloxd", "system/ubloxd", ["./ubloxd"], ublox, enabled=TICI),
|
2024-03-12 17:13:13 -07:00
|
|
|
PythonProcess("pigeond", "system.ubloxd.pigeond", ublox, enabled=TICI),
|
2024-09-12 14:10:18 -07:00
|
|
|
PythonProcess("plannerd", "selfdrive.controls.plannerd", not_long_maneuver),
|
|
|
|
|
PythonProcess("maneuversd", "tools.longitudinal_maneuvers.maneuversd", long_maneuver),
|
2023-08-24 06:00:55 -07:00
|
|
|
PythonProcess("radard", "selfdrive.controls.radard", only_onroad),
|
2024-06-05 15:58:00 -07:00
|
|
|
PythonProcess("hardwared", "system.hardware.hardwared", always_run),
|
2024-05-20 22:39:25 -07:00
|
|
|
PythonProcess("tombstoned", "system.tombstoned", always_run, enabled=not PC),
|
2024-05-25 12:22:02 -07:00
|
|
|
PythonProcess("updated", "system.updated.updated", only_offroad, enabled=not PC),
|
2023-08-24 06:00:55 -07:00
|
|
|
PythonProcess("uploader", "system.loggerd.uploader", always_run),
|
2024-05-20 22:39:25 -07:00
|
|
|
PythonProcess("statsd", "system.statsd", always_run),
|
2021-08-19 16:00:05 -07:00
|
|
|
|
2022-10-06 13:47:09 -07:00
|
|
|
# debug procs
|
2023-08-24 06:00:55 -07:00
|
|
|
NativeProcess("bridge", "cereal/messaging", ["./bridge"], notcar),
|
2023-12-01 21:13:37 -08:00
|
|
|
PythonProcess("webrtcd", "system.webrtc.webrtcd", notcar),
|
2023-08-24 06:00:55 -07:00
|
|
|
PythonProcess("webjoystick", "tools.bodyteleop.web", notcar),
|
2024-09-23 20:47:28 -07:00
|
|
|
PythonProcess("joystick", "tools.joystick.joystick_control", and_(joystick, iscar)),
|
2021-03-05 11:03:23 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
managed_processes = {p.name: p for p in procs}
|