mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-02 14:13:44 +08:00
FrogPilot 0.9.7
This commit is contained in:
@@ -18,6 +18,8 @@ from openpilot.system.athena.registration import register, UNREGISTERED_DONGLE_I
|
||||
from openpilot.common.swaglog import cloudlog, add_file_handler
|
||||
from openpilot.system.version import get_build_metadata, terms_version, training_version
|
||||
|
||||
from openpilot.selfdrive.frogpilot.frogpilot_functions import convert_params, frogpilot_boot_functions, setup_frogpilot, uninstall_frogpilot
|
||||
from openpilot.selfdrive.frogpilot.frogpilot_variables import frogpilot_default_params, get_frogpilot_toggles, params_memory
|
||||
|
||||
|
||||
def manager_init() -> None:
|
||||
@@ -32,13 +34,35 @@ def manager_init() -> None:
|
||||
if build_metadata.release_channel:
|
||||
params.clear_all(ParamKeyType.DEVELOPMENT_ONLY)
|
||||
|
||||
# FrogPilot variables
|
||||
setup_frogpilot(build_metadata)
|
||||
params_storage = Params("/persist/params")
|
||||
convert_params(params_storage)
|
||||
|
||||
default_params: list[tuple[str, str | bytes]] = [
|
||||
("AlwaysOnDM", "0"),
|
||||
("CarParamsPersistent", ""),
|
||||
("CompletedTrainingVersion", "0"),
|
||||
("DisengageOnAccelerator", "0"),
|
||||
("ExperimentalLongitudinalEnabled", "0"),
|
||||
("ExperimentalMode", "0"),
|
||||
("ExperimentalModeConfirmed", "0"),
|
||||
("GithubSshKeys", ""),
|
||||
("GithubUsername", ""),
|
||||
("GsmApn", ""),
|
||||
("GsmMetered", "1"),
|
||||
("GsmRoaming", "1"),
|
||||
("HasAcceptedTerms", "0"),
|
||||
("IsLdwEnabled", "0"),
|
||||
("IsMetric", "0"),
|
||||
("LanguageSetting", "main_en"),
|
||||
("NavSettingLeftSide", "0"),
|
||||
("NavSettingTime24h", "0"),
|
||||
("OpenpilotEnabledToggle", "1"),
|
||||
("RecordFront", "0"),
|
||||
("SshEnabled", "0"),
|
||||
("TetheringEnabled", "0"),
|
||||
("UpdaterAvailableBranches", ""),
|
||||
("LongitudinalPersonality", str(log.LongitudinalPersonality.standard)),
|
||||
]
|
||||
if not PC:
|
||||
@@ -48,9 +72,18 @@ def manager_init() -> None:
|
||||
params.put_bool("RecordFront", True)
|
||||
|
||||
# set unset params
|
||||
for k, v in default_params:
|
||||
if params.get(k) is None:
|
||||
params.put(k, v)
|
||||
reset_toggles = params.get_bool("DoToggleReset")
|
||||
for k, v in default_params + [(k, v) for k, v, _ in frogpilot_default_params]:
|
||||
if params.get(k) is None or reset_toggles:
|
||||
if params_storage.get(k) is None or reset_toggles:
|
||||
params.put(k, v)
|
||||
params_storage.remove(k)
|
||||
else:
|
||||
params.put(k, params_storage.get(k))
|
||||
else:
|
||||
params_storage.put(k, params.get(k))
|
||||
params.remove("DoToggleReset")
|
||||
frogpilot_boot_functions(build_metadata, params_storage)
|
||||
|
||||
# Create folders needed for msgq
|
||||
try:
|
||||
@@ -127,14 +160,19 @@ def manager_thread() -> None:
|
||||
ignore.append("pandad")
|
||||
ignore += [x for x in os.getenv("BLOCK", "").split(",") if len(x) > 0]
|
||||
|
||||
sm = messaging.SubMaster(['deviceState', 'carParams'], poll='deviceState')
|
||||
sm = messaging.SubMaster(['deviceState', 'carParams', 'frogpilotPlan'], poll='deviceState')
|
||||
pm = messaging.PubMaster(['managerState'])
|
||||
|
||||
write_onroad_params(False, params)
|
||||
ensure_running(managed_processes.values(), False, params=params, CP=sm['carParams'], not_run=ignore)
|
||||
ensure_running(managed_processes.values(), False, params=params, CP=sm['carParams'], not_run=ignore, classic_model=False, frogpilot_toggles=get_frogpilot_toggles())
|
||||
|
||||
started_prev = False
|
||||
|
||||
# FrogPilot variables
|
||||
frogpilot_toggles = get_frogpilot_toggles()
|
||||
|
||||
classic_model = frogpilot_toggles.classic_model
|
||||
|
||||
while True:
|
||||
sm.update(1000)
|
||||
|
||||
@@ -142,8 +180,13 @@ def manager_thread() -> None:
|
||||
|
||||
if started and not started_prev:
|
||||
params.clear_all(ParamKeyType.CLEAR_ON_ONROAD_TRANSITION)
|
||||
|
||||
# FrogPilot variables
|
||||
classic_model = frogpilot_toggles.classic_model
|
||||
|
||||
elif not started and started_prev:
|
||||
params.clear_all(ParamKeyType.CLEAR_ON_OFFROAD_TRANSITION)
|
||||
params_memory.clear_all(ParamKeyType.CLEAR_ON_OFFROAD_TRANSITION)
|
||||
|
||||
# update onroad params, which drives pandad's safety setter thread
|
||||
if started != started_prev:
|
||||
@@ -151,7 +194,7 @@ def manager_thread() -> None:
|
||||
|
||||
started_prev = started
|
||||
|
||||
ensure_running(managed_processes.values(), started, params=params, CP=sm['carParams'], not_run=ignore)
|
||||
ensure_running(managed_processes.values(), started, params=params, CP=sm['carParams'], not_run=ignore, classic_model=classic_model, frogpilot_toggles=frogpilot_toggles)
|
||||
|
||||
running = ' '.join("{}{}\u001b[0m".format("\u001b[32m" if p.proc.is_alive() else "\u001b[31m", p.name)
|
||||
for p in managed_processes.values() if p.proc)
|
||||
@@ -174,6 +217,9 @@ def manager_thread() -> None:
|
||||
if shutdown:
|
||||
break
|
||||
|
||||
# Update FrogPilot parameters
|
||||
if sm['frogpilotPlan'].togglesUpdated:
|
||||
frogpilot_toggles = get_frogpilot_toggles()
|
||||
|
||||
def main() -> None:
|
||||
manager_init()
|
||||
@@ -194,7 +240,7 @@ def main() -> None:
|
||||
params = Params()
|
||||
if params.get_bool("DoUninstall"):
|
||||
cloudlog.warning("uninstalling")
|
||||
HARDWARE.uninstall()
|
||||
uninstall_frogpilot()
|
||||
elif params.get_bool("DoReboot"):
|
||||
cloudlog.warning("reboot")
|
||||
HARDWARE.reboot()
|
||||
|
||||
@@ -238,7 +238,7 @@ class DaemonProcess(ManagerProcess):
|
||||
self.params = None
|
||||
|
||||
@staticmethod
|
||||
def should_run(started, params, CP):
|
||||
def should_run(started, params, CP, classic_model, frogpilot_toggles):
|
||||
return True
|
||||
|
||||
def prepare(self) -> None:
|
||||
@@ -274,13 +274,13 @@ class DaemonProcess(ManagerProcess):
|
||||
|
||||
|
||||
def ensure_running(procs: ValuesView[ManagerProcess], started: bool, params=None, CP: car.CarParams=None,
|
||||
not_run: list[str] | None=None) -> list[ManagerProcess]:
|
||||
not_run: list[str] | None=None, classic_model=False, frogpilot_toggles=None) -> list[ManagerProcess]:
|
||||
if not_run is None:
|
||||
not_run = []
|
||||
|
||||
running = []
|
||||
for p in procs:
|
||||
if p.enabled and p.name not in not_run and p.should_run(started, params, CP):
|
||||
if p.enabled and p.name not in not_run and p.should_run(started, params, CP, classic_model, frogpilot_toggles):
|
||||
running.append(p)
|
||||
else:
|
||||
p.stop(block=False)
|
||||
|
||||
@@ -7,55 +7,70 @@ from openpilot.system.manager.process import PythonProcess, NativeProcess, Daemo
|
||||
|
||||
WEBCAM = os.getenv("USE_WEBCAM") is not None
|
||||
|
||||
def driverview(started: bool, params: Params, CP: car.CarParams) -> bool:
|
||||
def driverview(started: bool, params: Params, CP: car.CarParams, classic_model, frogpilot_toggles) -> bool:
|
||||
return started or params.get_bool("IsDriverViewEnabled")
|
||||
|
||||
def notcar(started: bool, params: Params, CP: car.CarParams) -> bool:
|
||||
def notcar(started: bool, params: Params, CP: car.CarParams, classic_model, frogpilot_toggles) -> bool:
|
||||
return started and CP.notCar
|
||||
|
||||
def iscar(started: bool, params: Params, CP: car.CarParams) -> bool:
|
||||
def iscar(started: bool, params: Params, CP: car.CarParams, classic_model, frogpilot_toggles) -> bool:
|
||||
return started and not CP.notCar
|
||||
|
||||
def logging(started, params, CP: car.CarParams) -> bool:
|
||||
def logging(started, params, CP: car.CarParams, classic_model, frogpilot_toggles) -> bool:
|
||||
run = (not CP.notCar) or not params.get_bool("DisableLogging")
|
||||
return started and run
|
||||
|
||||
def ublox_available() -> bool:
|
||||
return os.path.exists('/dev/ttyHS0') and not os.path.exists('/persist/comma/use-quectel-gps')
|
||||
|
||||
def ublox(started, params, CP: car.CarParams) -> bool:
|
||||
def ublox(started, params, CP: car.CarParams, classic_model, frogpilot_toggles) -> bool:
|
||||
use_ublox = ublox_available()
|
||||
if use_ublox != params.get_bool("UbloxAvailable"):
|
||||
params.put_bool("UbloxAvailable", use_ublox)
|
||||
return started and use_ublox
|
||||
|
||||
def qcomgps(started, params, CP: car.CarParams) -> bool:
|
||||
def qcomgps(started, params, CP: car.CarParams, classic_model, frogpilot_toggles) -> bool:
|
||||
return started and not ublox_available()
|
||||
|
||||
def always_run(started, params, CP: car.CarParams) -> bool:
|
||||
def always_run(started, params, CP: car.CarParams, classic_model, frogpilot_toggles) -> bool:
|
||||
return True
|
||||
|
||||
def only_onroad(started: bool, params, CP: car.CarParams) -> bool:
|
||||
def only_onroad(started: bool, params, CP: car.CarParams, classic_model, frogpilot_toggles) -> bool:
|
||||
return started
|
||||
|
||||
def only_offroad(started, params, CP: car.CarParams) -> bool:
|
||||
def only_offroad(started, params, CP: car.CarParams, classic_model, frogpilot_toggles) -> bool:
|
||||
return not started
|
||||
|
||||
# FrogPilot functions
|
||||
def allow_logging(started, params, CP: car.CarParams, classic_model, frogpilot_toggles) -> bool:
|
||||
return not frogpilot_toggles.no_logging and logging(started, params, CP, classic_model, frogpilot_toggles)
|
||||
|
||||
def allow_uploads(started, params, CP: car.CarParams, classic_model, frogpilot_toggles) -> bool:
|
||||
return not frogpilot_toggles.no_uploads
|
||||
|
||||
def run_classic_modeld(started, params, CP: car.CarParams, classic_model, frogpilot_toggles) -> bool:
|
||||
return started and classic_model
|
||||
|
||||
def run_new_modeld(started, params, CP: car.CarParams, classic_model, frogpilot_toggles) -> bool:
|
||||
return started and not classic_model
|
||||
|
||||
procs = [
|
||||
DaemonProcess("manage_athenad", "system.athena.manage_athenad", "AthenadPid"),
|
||||
|
||||
NativeProcess("camerad", "system/camerad", ["./camerad"], driverview),
|
||||
NativeProcess("logcatd", "system/logcatd", ["./logcatd"], only_onroad),
|
||||
NativeProcess("proclogd", "system/proclogd", ["./proclogd"], only_onroad),
|
||||
PythonProcess("logmessaged", "system.logmessaged", always_run),
|
||||
NativeProcess("logcatd", "system/logcatd", ["./logcatd"], allow_logging),
|
||||
NativeProcess("proclogd", "system/proclogd", ["./proclogd"], allow_logging),
|
||||
PythonProcess("logmessaged", "system.logmessaged", allow_logging),
|
||||
PythonProcess("micd", "system.micd", iscar),
|
||||
PythonProcess("timed", "system.timed", always_run, enabled=not PC),
|
||||
|
||||
PythonProcess("dmonitoringmodeld", "selfdrive.modeld.dmonitoringmodeld", driverview, enabled=(not PC or WEBCAM)),
|
||||
NativeProcess("encoderd", "system/loggerd", ["./encoderd"], only_onroad),
|
||||
NativeProcess("encoderd", "system/loggerd", ["./encoderd"], allow_logging),
|
||||
NativeProcess("stream_encoderd", "system/loggerd", ["./encoderd", "--stream"], notcar),
|
||||
NativeProcess("loggerd", "system/loggerd", ["./loggerd"], logging),
|
||||
NativeProcess("modeld", "selfdrive/modeld", ["./modeld"], only_onroad),
|
||||
NativeProcess("loggerd", "system/loggerd", ["./loggerd"], allow_logging),
|
||||
NativeProcess("modeld", "selfdrive/modeld", ["./modeld"], run_new_modeld),
|
||||
NativeProcess("mapsd", "selfdrive/navd", ["./mapsd"], run_classic_modeld),
|
||||
PythonProcess("navmodeld", "selfdrive.classic_modeld.navmodeld", run_classic_modeld),
|
||||
NativeProcess("sensord", "system/sensord", ["./sensord"], only_onroad, enabled=not PC),
|
||||
NativeProcess("ui", "selfdrive/ui", ["./ui"], always_run, watchdog_max_dt=(5 if not PC else None)),
|
||||
PythonProcess("soundd", "selfdrive.ui.soundd", only_onroad),
|
||||
@@ -69,7 +84,7 @@ procs = [
|
||||
PythonProcess("dmonitoringd", "selfdrive.monitoring.dmonitoringd", driverview, enabled=(not PC or WEBCAM)),
|
||||
PythonProcess("qcomgpsd", "system.qcomgpsd.qcomgpsd", qcomgps, enabled=TICI),
|
||||
#PythonProcess("ugpsd", "system.ugpsd", only_onroad, enabled=TICI),
|
||||
PythonProcess("navd", "selfdrive.navd.navd", only_onroad),
|
||||
PythonProcess("navd", "selfdrive.navd.navd", run_classic_modeld),
|
||||
PythonProcess("pandad", "selfdrive.pandad.pandad", always_run),
|
||||
PythonProcess("paramsd", "selfdrive.locationd.paramsd", only_onroad),
|
||||
NativeProcess("ubloxd", "system/ubloxd", ["./ubloxd"], ublox, enabled=TICI),
|
||||
@@ -78,14 +93,20 @@ procs = [
|
||||
PythonProcess("radard", "selfdrive.controls.radard", only_onroad),
|
||||
PythonProcess("hardwared", "system.hardware.hardwared", always_run),
|
||||
PythonProcess("tombstoned", "system.tombstoned", always_run, enabled=not PC),
|
||||
PythonProcess("updated", "system.updated.updated", only_offroad, enabled=not PC),
|
||||
PythonProcess("uploader", "system.loggerd.uploader", always_run),
|
||||
PythonProcess("statsd", "system.statsd", always_run),
|
||||
PythonProcess("updated", "system.updated.updated", always_run, enabled=not PC),
|
||||
PythonProcess("uploader", "system.loggerd.uploader", allow_uploads),
|
||||
PythonProcess("statsd", "system.statsd", allow_logging),
|
||||
|
||||
# debug procs
|
||||
NativeProcess("bridge", "cereal/messaging", ["./bridge"], notcar),
|
||||
PythonProcess("webrtcd", "system.webrtc.webrtcd", notcar),
|
||||
PythonProcess("webjoystick", "tools.bodyteleop.web", notcar),
|
||||
|
||||
# FrogPilot processes
|
||||
NativeProcess("classic_modeld", "selfdrive/classic_modeld", ["./classic_modeld"], run_classic_modeld),
|
||||
PythonProcess("fleet_manager", "selfdrive.frogpilot.fleetmanager.fleet_manager", always_run),
|
||||
PythonProcess("frogpilot_process", "selfdrive.frogpilot.frogpilot_process", always_run),
|
||||
PythonProcess("mapd", "selfdrive.frogpilot.navigation.mapd", always_run),
|
||||
]
|
||||
|
||||
managed_processes = {p.name: p for p in procs}
|
||||
|
||||
Reference in New Issue
Block a user