FrogPilot utilities

This commit is contained in:
James
2025-12-09 05:28:24 -07:00
parent 95583fb304
commit 2f00fc348d
3 changed files with 347 additions and 7 deletions
+10 -7
View File
@@ -8,15 +8,16 @@ from openpilot.common.params import Params
from openpilot.common.realtime import DT_MDL, Priority, Ratekeeper, config_realtime_process
from openpilot.common.time_helpers import system_time_valid
from openpilot.frogpilot.common.frogpilot_utilities import ThreadManager, is_url_pingable
from openpilot.frogpilot.controls.frogpilot_planner import FrogPilotPlanner
from openpilot.frogpilot.system.frogpilot_stats import send_stats
from openpilot.frogpilot.system.frogpilot_tracking import FrogPilotTracking
ASSET_CHECK_RATE = (1 / DT_MDL)
def check_assets(params_memory):
def check_assets(thread_manager, params_memory):
def transition_offroad(frogpilot_planner, time_validated, sm, params):
def transition_offroad(frogpilot_planner, thread_manager, time_validated, sm, params):
params.put("LastGPSPosition", json.dumps(frogpilot_planner.gps_position))
if time_validated:
@@ -24,7 +25,7 @@ def transition_offroad(frogpilot_planner, time_validated, sm, params):
def transition_onroad():
def update_checks(now, params, params_memory, boot_run=False):
def update_checks(now, thread_manager, params, params_memory, boot_run=False):
while not (is_url_pingable("https://github.com") or is_url_pingable("https://gitlab.com")):
time.sleep(60)
@@ -45,6 +46,8 @@ def frogpilot_thread():
params = Params(return_defaults=True)
params_memory = Params(memory=True)
thread_manager = ThreadManager()
run_update_checks = False
started_previously = False
time_validated = False
@@ -57,7 +60,7 @@ def frogpilot_thread():
started = sm["deviceState"].started
if not started and started_previously:
transition_offroad(frogpilot_planner, time_validated, sm, params)
transition_offroad(frogpilot_planner, thread_manager, time_validated, sm, params)
run_update_checks = True
elif started and not started_previously:
@@ -78,13 +81,13 @@ def frogpilot_thread():
started_previously = started
if rate_keeper.frame % ASSET_CHECK_RATE == 0:
check_assets(params_memory)
check_assets(thread_manager, params_memory)
run_update_checks |= now.second == 0 and (now.minute % 60 == 0)
run_update_checks &= time_validated
if run_update_checks:
thread_manager.run_with_lock(update_checks, (now, params, params_memory))
thread_manager.run_with_lock(update_checks, (now, thread_manager, params, params_memory))
run_update_checks = False
elif not time_validated:
@@ -93,7 +96,7 @@ def frogpilot_thread():
continue
thread_manager.run_with_lock(send_stats, (params))
thread_manager.run_with_lock(update_checks, (now, params, params_memory, True))
thread_manager.run_with_lock(update_checks, (now, thread_manager, params, params_memory, True))
rate_keeper.keep_time()