mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-24 01:33:46 +08:00
FrogPilot base
This commit is contained in:
@@ -212,6 +212,8 @@ def hardware_thread(end_event, hw_queue) -> None:
|
||||
|
||||
fan_controller = None
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
while not end_event.is_set():
|
||||
sm.update(PANDA_STATES_TIMEOUT)
|
||||
|
||||
@@ -292,6 +294,8 @@ def hardware_thread(end_event, hw_queue) -> None:
|
||||
if fan_controller is not None:
|
||||
msg.deviceState.fanSpeedPercentDesired = fan_controller.update(all_comp_temp, onroad_conditions["ignition"])
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
is_offroad_for_5_min = (started_ts is None) and ((not started_seen) or (off_ts is None) or (time.monotonic() - off_ts > 60 * 5))
|
||||
if is_offroad_for_5_min and offroad_comp_temp > OFFROAD_DANGER_TEMP:
|
||||
# if device is offroad and already hot without the extra onroad load,
|
||||
@@ -341,6 +345,8 @@ def hardware_thread(end_event, hw_queue) -> None:
|
||||
if started_ts is None:
|
||||
should_start = should_start and all(startup_conditions.values())
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
if should_start != should_start_prev or (count == 0):
|
||||
params.put_bool("IsEngaged", False)
|
||||
engaged_prev = False
|
||||
@@ -410,6 +416,8 @@ def hardware_thread(end_event, hw_queue) -> None:
|
||||
msg.deviceState.thermalStatus = thermal_status
|
||||
pm.send("deviceState", msg)
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
# Log to statsd
|
||||
statlog.gauge("free_space_percent", msg.deviceState.freeSpacePercent)
|
||||
statlog.gauge("gpu_usage_percent", msg.deviceState.gpuUsagePercent)
|
||||
@@ -463,6 +471,8 @@ def hardware_thread(end_event, hw_queue) -> None:
|
||||
count += 1
|
||||
should_start_prev = should_start
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
|
||||
def main():
|
||||
hw_queue = queue.Queue(maxsize=1)
|
||||
|
||||
@@ -26,7 +26,14 @@ namespace Path {
|
||||
if (const char *env = getenv("LOG_ROOT")) {
|
||||
return env;
|
||||
}
|
||||
return Hardware::PC() ? Path::comma_home() + "/media/0/realdata" : "/data/media/0/realdata";
|
||||
|
||||
if (Hardware::PC()) {
|
||||
return Path::comma_home() + "/media/0/realdata";
|
||||
}
|
||||
|
||||
// FrogPilot variables
|
||||
|
||||
return "/data/media/0/realdata";
|
||||
}
|
||||
|
||||
inline std::string params() {
|
||||
|
||||
@@ -27,3 +27,6 @@ def get_available_bytes(default: int) -> int:
|
||||
available_bytes = default
|
||||
|
||||
return available_bytes
|
||||
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
@@ -248,6 +248,9 @@ def main(exit_event: threading.Event = None) -> None:
|
||||
uploader = Uploader(dongle_id, Paths.log_root())
|
||||
|
||||
backoff = 0.1
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
while not exit_event.is_set():
|
||||
sm.update(0)
|
||||
offroad = params.get_bool("IsOffroad")
|
||||
@@ -268,6 +271,8 @@ def main(exit_event: threading.Event = None) -> None:
|
||||
if allow_sleep:
|
||||
time.sleep(backoff + random.uniform(0, backoff))
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -21,6 +21,8 @@ from openpilot.common.swaglog import cloudlog, add_file_handler
|
||||
from openpilot.system.version import get_build_metadata, terms_version, training_version
|
||||
from openpilot.system.hardware.hw import Paths
|
||||
|
||||
from openpilot.frogpilot.common.frogpilot_functions import frogpilot_boot_functions, install_frogpilot, uninstall_frogpilot
|
||||
|
||||
|
||||
def manager_init() -> None:
|
||||
save_bootlog()
|
||||
@@ -38,6 +40,8 @@ def manager_init() -> None:
|
||||
if params.get_bool("RecordFrontLock"):
|
||||
params.put_bool("RecordFront", True)
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
# set unset params to their default value
|
||||
for k in params.all_keys():
|
||||
default_value = params.get_default_value(k)
|
||||
@@ -93,6 +97,10 @@ def manager_init() -> None:
|
||||
for p in managed_processes.values():
|
||||
p.prepare()
|
||||
|
||||
# FrogPilot variables
|
||||
install_frogpilot()
|
||||
frogpilot_boot_functions()
|
||||
|
||||
|
||||
def manager_cleanup() -> None:
|
||||
# send signals to kill all procs
|
||||
@@ -129,6 +137,8 @@ def manager_thread() -> None:
|
||||
started_prev = False
|
||||
ignition_prev = False
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
while True:
|
||||
sm.update(1000)
|
||||
|
||||
@@ -136,9 +146,13 @@ def manager_thread() -> None:
|
||||
|
||||
if started and not started_prev:
|
||||
params.clear_all(ParamKeyFlag.CLEAR_ON_ONROAD_TRANSITION)
|
||||
|
||||
# FrogPilot variables
|
||||
elif not started and started_prev:
|
||||
params.clear_all(ParamKeyFlag.CLEAR_ON_OFFROAD_TRANSITION)
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
ignition = any(ps.ignitionLine or ps.ignitionCan for ps in sm['pandaStates'] if ps.pandaType != log.PandaState.PandaType.unknown)
|
||||
if ignition and not ignition_prev:
|
||||
params.clear_all(ParamKeyFlag.CLEAR_ON_IGNITION_ON)
|
||||
@@ -181,6 +195,8 @@ def manager_thread() -> None:
|
||||
if shutdown:
|
||||
break
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
|
||||
def main() -> None:
|
||||
manager_init()
|
||||
@@ -201,7 +217,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()
|
||||
|
||||
@@ -4,7 +4,7 @@ import platform
|
||||
|
||||
from cereal import car
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.system.hardware import PC, TICI
|
||||
from openpilot.system.hardware import HARDWARE, PC, TICI
|
||||
from openpilot.system.manager.process import PythonProcess, NativeProcess, DaemonProcess
|
||||
|
||||
WEBCAM = os.getenv("USE_WEBCAM") is not None
|
||||
@@ -61,6 +61,8 @@ def or_(*fns):
|
||||
def and_(*fns):
|
||||
return lambda *args: operator.and_(*(fn(*args) for fn in fns))
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
procs = [
|
||||
DaemonProcess("manage_athenad", "system.athena.manage_athenad", "AthenadPid"),
|
||||
|
||||
@@ -80,7 +82,6 @@ procs = [
|
||||
PythonProcess("dmonitoringmodeld", "selfdrive.modeld.dmonitoringmodeld", driverview, enabled=(WEBCAM or not PC)),
|
||||
|
||||
PythonProcess("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", driverview),
|
||||
PythonProcess("locationd", "selfdrive.locationd.locationd", only_onroad),
|
||||
NativeProcess("_pandad", "selfdrive/pandad", ["./pandad"], always_run, enabled=False),
|
||||
@@ -115,4 +116,13 @@ procs = [
|
||||
PythonProcess("joystick", "tools.joystick.joystick_control", and_(joystick, iscar)),
|
||||
]
|
||||
|
||||
# FrogPilot variables
|
||||
if HARDWARE.get_device_type() == "mici":
|
||||
procs.append(PythonProcess("ui", "selfdrive.ui.ui", always_run))
|
||||
elif TICI:
|
||||
procs.append(NativeProcess("ui", "selfdrive/ui", ["./ui"], always_run, watchdog_max_dt=5)),
|
||||
procs += [
|
||||
PythonProcess("frogpilot_process", "frogpilot.frogpilot_process", always_run),
|
||||
]
|
||||
|
||||
managed_processes = {p.name: p for p in procs}
|
||||
|
||||
@@ -24,6 +24,9 @@ def set_time(new_time):
|
||||
cloudlog.exception("timed.failed_setting_time")
|
||||
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
|
||||
def main() -> NoReturn:
|
||||
"""
|
||||
timed has two responsibilities:
|
||||
@@ -38,6 +41,9 @@ def main() -> NoReturn:
|
||||
|
||||
pm = messaging.PubMaster(['clocks'])
|
||||
sm = messaging.SubMaster([gps_location_service])
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
while True:
|
||||
sm.update(1000)
|
||||
|
||||
@@ -56,6 +62,9 @@ def main() -> NoReturn:
|
||||
continue
|
||||
|
||||
set_time(gps_time)
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -27,6 +27,8 @@ FONT_SIZE = 96
|
||||
LINE_HEIGHT = 104
|
||||
DARKGRAY = (55, 55, 55, 255)
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
|
||||
def clamp(value, min_value, max_value):
|
||||
return max(min(value, max_value), min_value)
|
||||
|
||||
@@ -410,6 +410,7 @@ class Updater:
|
||||
finalize_update()
|
||||
cloudlog.info("finalize success!")
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
def main() -> None:
|
||||
params = Params()
|
||||
@@ -449,9 +450,14 @@ def main() -> None:
|
||||
|
||||
# Run the update loop
|
||||
first_run = True
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
while True:
|
||||
wait_helper.ready_event.clear()
|
||||
|
||||
# FrogPilot variables
|
||||
|
||||
# Attempt an update
|
||||
exception = None
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user