From c8a5e91c0dcac21d8fb3e8a3cfb14880a93193e1 Mon Sep 17 00:00:00 2001 From: Kevin Robert Keegan Date: Sun, 19 Dec 2021 15:50:05 -0800 Subject: [PATCH] :page_facing_up: Add Toggle to Enable Automatic Raw Log Uploading Brings back the raw log toggle that was used prior to version 8.12. Upload RLogs First then Videos This reverts in part commit 2e0c73fc0cbac64e442085390dd22e6b408d0478. --- selfdrive/common/params.cc | 1 + selfdrive/loggerd/uploader.py | 23 +++++++++++++++++++++-- selfdrive/ui/qt/offroad/settings.cc | 6 ++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/selfdrive/common/params.cc b/selfdrive/common/params.cc index 7c46b3c7449535..41796a35725bf9 100644 --- a/selfdrive/common/params.cc +++ b/selfdrive/common/params.cc @@ -158,6 +158,7 @@ std::unordered_map keys = { {"TrainingVersion", PERSISTENT}, {"UpdateAvailable", CLEAR_ON_MANAGER_START}, {"UpdateFailedCount", CLEAR_ON_MANAGER_START}, + {"UploadRaw", PERSISTENT}, {"Version", PERSISTENT}, {"VisionRadarToggle", PERSISTENT}, {"ApiCache_Device", PERSISTENT}, diff --git a/selfdrive/loggerd/uploader.py b/selfdrive/loggerd/uploader.py index 2013a522bc7a9c..7abf580788b3fc 100644 --- a/selfdrive/loggerd/uploader.py +++ b/selfdrive/loggerd/uploader.py @@ -70,10 +70,16 @@ def __init__(self, dongle_id, root): self.immediate_folders = ["crash/", "boot/"] self.immediate_priority = {"qlog.bz2": 0, "qcamera.ts": 1} + self.high_priority = {"rlog.bz2": 0} + self.normal_priority = {"fcamera.hevc": 1, "dcamera.hevc": 2, "ecamera.hevc": 3} def get_upload_sort(self, name): if name in self.immediate_priority: return self.immediate_priority[name] + if name in self.high_priority: + return self.high_priority[name] + 100 + if name in self.normal_priority: + return self.normal_priority[name] + 300 return 1000 def list_upload_files(self): @@ -114,7 +120,7 @@ def list_upload_files(self): yield (name, key, fn) - def next_file_to_upload(self): + def next_file_to_upload(self, with_raw): upload_files = list(self.list_upload_files()) for name, key, fn in upload_files: @@ -125,6 +131,17 @@ def next_file_to_upload(self): if name in self.immediate_priority: return (key, fn) + if with_raw: + # then upload the full log files, rear and front camera files + for name, key, fn in upload_files: + if name in self.high_priority: + return (key, fn) + + # Could add a param here to disable full video uploads + for name, key, fn in upload_files: + if name in self.normal_priority: + return (key, fn) + return None def do_upload(self, key, fn): @@ -237,7 +254,9 @@ def uploader_fn(exit_event): time.sleep(60 if offroad else 5) continue - d = uploader.next_file_to_upload() + allow_raw_upload = params.get_bool("UploadRaw") + + d = uploader.next_file_to_upload(with_raw=allow_raw_upload) if d is None: # Nothing to upload if allow_sleep: time.sleep(60 if offroad else 5) diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index 103beb2c195ed4..c743feded4e368 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -59,6 +59,12 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { "Pressing the gas pedal will NOT disengage openpilot, while this is the default design for Toyota, this is NOT enabled by default for OpenPilot. Use at your own risk!!", "../assets/offroad/icon_gas.png", }, + { + "UploadRaw", + "Upload Raw Logs", + "Upload full logs and full resolution video by default while on Wi-Fi. If not enabled, individual logs can be marked for upload at useradmin.comma.ai.", + "../assets/offroad/icon_network.png", + }, { "RecordFront", "Record and Upload Driver Camera",