From 00bf1e9f08edfc37f4b1da95335b0a271a8a66a3 Mon Sep 17 00:00:00 2001 From: Quantizr <9859727+Quantizr@users.noreply.github.com> Date: Tue, 10 Sep 2024 19:34:31 -0700 Subject: [PATCH 1/6] testing closet changes --- selfdrive/selfdrived/selfdrived.py | 8 ++++---- selfdrive/ui/soundd.py | 5 ++++- system/loggerd/uploader.py | 5 +++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/selfdrive/selfdrived/selfdrived.py b/selfdrive/selfdrived/selfdrived.py index 255ce080df4bab..98fec9aa962d87 100755 --- a/selfdrive/selfdrived/selfdrived.py +++ b/selfdrive/selfdrived/selfdrived.py @@ -154,7 +154,7 @@ def update_events(self, CS): if not self.CP.pcmCruise and CS.vCruise > 250 and resume_pressed: self.events.add(EventName.resumeBlocked) - if not self.CP.notCar: + if not self.CP.notCar and not TESTING_CLOSET: self.events.add_from_msg(self.sm['driverMonitoringState'].events) # Add car events, ignore if CAN isn't valid @@ -277,12 +277,12 @@ def update_events(self, CS): else: self.logged_comm_issue = None - if not self.CP.notCar: + if not self.CP.notCar and not TESTING_CLOSET: if not self.sm['livePose'].posenetOK: self.events.add(EventName.posenetInvalid) if not self.sm['livePose'].inputsOK: self.events.add(EventName.locationdTemporaryError) - if not self.sm['liveParameters'].valid and not TESTING_CLOSET and (not SIMULATION or REPLAY): + if not self.sm['liveParameters'].valid and (not SIMULATION or REPLAY): self.events.add(EventName.paramsdTemporaryError) # conservative HW alert. if the data or frequency are off, locationd will throw an error @@ -370,7 +370,7 @@ def data_sample(self): self.sm.ignore_alive.append('wideRoadCameraState') self.sm.ignore_valid.append('wideRoadCameraState') - if REPLAY and any(ps.controlsAllowed for ps in self.sm['pandaStates']): + if (REPLAY and any(ps.controlsAllowed for ps in self.sm['pandaStates'])) or TESTING_CLOSET: self.state_machine.state = State.enabled self.initialized = True diff --git a/selfdrive/ui/soundd.py b/selfdrive/ui/soundd.py index 3cd6ae582078b7..25c4e2c230b7c2 100644 --- a/selfdrive/ui/soundd.py +++ b/selfdrive/ui/soundd.py @@ -1,3 +1,4 @@ +import os import math import numpy as np import time @@ -13,6 +14,8 @@ from openpilot.system import micd +TESTING_CLOSET = "TESTING_CLOSET" in os.environ + SAMPLE_RATE = 48000 SAMPLE_BUFFER = 4096 # (approx 100ms) MAX_VOLUME = 1.0 @@ -123,7 +126,7 @@ def get_audible_alert(self, sm): def calculate_volume(self, weighted_db): volume = ((weighted_db - AMBIENT_DB) / DB_SCALE) * (MAX_VOLUME - MIN_VOLUME) + MIN_VOLUME - return math.pow(10, (np.clip(volume, MIN_VOLUME, MAX_VOLUME) - 1)) + return math.pow(10, (np.clip(volume, MIN_VOLUME, MAX_VOLUME) - (1 if "TESTING_CLOSET" not in os.environ else 2))) @retry(attempts=7, delay=3) def get_stream(self, sd): diff --git a/system/loggerd/uploader.py b/system/loggerd/uploader.py index 965d74bef8653d..e04cb4bd1e039f 100755 --- a/system/loggerd/uploader.py +++ b/system/loggerd/uploader.py @@ -30,6 +30,7 @@ allow_sleep = bool(os.getenv("UPLOADER_SLEEP", "1")) force_wifi = os.getenv("FORCEWIFI") is not None fake_upload = os.getenv("FAKEUPLOAD") is not None +TESTING_CLOSET = "TESTING_CLOSET" in os.environ class FakeRequest: @@ -83,7 +84,7 @@ def __init__(self, dongle_id: str, root: str): self.last_filename = "" self.immediate_folders = ["crash/", "boot/"] - self.immediate_priority = {"qlog": 0, "qlog.zst": 0, "qcamera.ts": 1} + self.immediate_priority = {"qlog": 0, "qlog.zst": 0, "qcamera.ts": 1} if not TESTING_CLOSET else {"rlog": 0, "rlog.zst": 0} def list_upload_files(self, metered: bool) -> Iterator[tuple[str, str, str]]: r = self.params.get("AthenadRecentlyViewedRoutes", encoding="utf8") @@ -170,7 +171,7 @@ def upload(self, name: str, key: str, fn: str, network_type: int, metered: bool) if sz == 0: # tag files of 0 size as uploaded success = True - elif name in self.immediate_priority and sz > UPLOAD_QLOG_QCAM_MAX_SIZE: + elif name in self.immediate_priority and sz > UPLOAD_QLOG_QCAM_MAX_SIZE and not TESTING_CLOSET: cloudlog.event("uploader_too_large", key=key, fn=fn, sz=sz) success = True else: From 8745170f479f1703ff9a73ef27b4b9fe0ab40984 Mon Sep 17 00:00:00 2001 From: Quantizr <9859727+Quantizr@users.noreply.github.com> Date: Tue, 10 Sep 2024 19:35:55 -0700 Subject: [PATCH 2/6] optionally specify jungle serial for can_replay --- tools/replay/can_replay.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/replay/can_replay.py b/tools/replay/can_replay.py index ff27b50067f9b4..27154efc9237e8 100755 --- a/tools/replay/can_replay.py +++ b/tools/replay/can_replay.py @@ -19,6 +19,7 @@ IGN_OFF = int(os.getenv("OFF", "0")) ENABLE_IGN = IGN_ON > 0 and IGN_OFF > 0 ENABLE_PWR = PWR_ON > 0 and PWR_OFF > 0 +SERIAL = os.getenv("SERIAL") def send_thread(j: PandaJungle, flock): @@ -65,7 +66,7 @@ def connect(): while True: # look for new devices for s in PandaJungle.list(): - if s not in serials: + if s not in serials and (SERIAL is None or s == SERIAL): print("starting send thread for", s) serials[s] = threading.Thread(target=send_thread, args=(PandaJungle(s), flashing_lock)) serials[s].start() From 5fd901cf4fc04834d544e576cf53a397feaaaa37 Mon Sep 17 00:00:00 2001 From: Quantizr <9859727+Quantizr@users.noreply.github.com> Date: Tue, 10 Sep 2024 19:39:50 -0700 Subject: [PATCH 3/6] use TESTING_CLOSET var --- selfdrive/ui/soundd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/soundd.py b/selfdrive/ui/soundd.py index 25c4e2c230b7c2..a0ca325ff4fefa 100644 --- a/selfdrive/ui/soundd.py +++ b/selfdrive/ui/soundd.py @@ -126,7 +126,7 @@ def get_audible_alert(self, sm): def calculate_volume(self, weighted_db): volume = ((weighted_db - AMBIENT_DB) / DB_SCALE) * (MAX_VOLUME - MIN_VOLUME) + MIN_VOLUME - return math.pow(10, (np.clip(volume, MIN_VOLUME, MAX_VOLUME) - (1 if "TESTING_CLOSET" not in os.environ else 2))) + return math.pow(10, (np.clip(volume, MIN_VOLUME, MAX_VOLUME) - (1 if not TESTING_CLOSET else 2))) @retry(attempts=7, delay=3) def get_stream(self, sd): From 018e7a4881a7dbf1b7e00d40ce499a4ea86dd976 Mon Sep 17 00:00:00 2001 From: Quantizr <9859727+Quantizr@users.noreply.github.com> Date: Thu, 12 Sep 2024 22:27:38 -0700 Subject: [PATCH 4/6] Revert "optionally specify jungle serial for can_replay" This reverts commit 8745170f479f1703ff9a73ef27b4b9fe0ab40984. --- tools/replay/can_replay.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/replay/can_replay.py b/tools/replay/can_replay.py index 27154efc9237e8..ff27b50067f9b4 100755 --- a/tools/replay/can_replay.py +++ b/tools/replay/can_replay.py @@ -19,7 +19,6 @@ IGN_OFF = int(os.getenv("OFF", "0")) ENABLE_IGN = IGN_ON > 0 and IGN_OFF > 0 ENABLE_PWR = PWR_ON > 0 and PWR_OFF > 0 -SERIAL = os.getenv("SERIAL") def send_thread(j: PandaJungle, flock): @@ -66,7 +65,7 @@ def connect(): while True: # look for new devices for s in PandaJungle.list(): - if s not in serials and (SERIAL is None or s == SERIAL): + if s not in serials: print("starting send thread for", s) serials[s] = threading.Thread(target=send_thread, args=(PandaJungle(s), flashing_lock)) serials[s].start() From 1dbe42f92df53a44845d4f515bff844b3e2589fc Mon Sep 17 00:00:00 2001 From: Quantizr <9859727+Quantizr@users.noreply.github.com> Date: Thu, 12 Sep 2024 22:31:37 -0700 Subject: [PATCH 5/6] no need to calibrate in testing closet --- selfdrive/locationd/calibrationd.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/selfdrive/locationd/calibrationd.py b/selfdrive/locationd/calibrationd.py index 6e154bf07cf83e..bc7e4d6405c0dd 100755 --- a/selfdrive/locationd/calibrationd.py +++ b/selfdrive/locationd/calibrationd.py @@ -41,6 +41,7 @@ PITCH_LIMITS = np.array([-0.09074112085129739, 0.17]) YAW_LIMITS = np.array([-0.06912048084718224, 0.06912048084718235]) DEBUG = os.getenv("DEBUG") is not None +TESTING_CLOSET = os.getenv("TESTING_CLOSET") is not None def is_calibration_valid(rpy: np.ndarray) -> bool: @@ -268,7 +269,7 @@ def main() -> NoReturn: timeout = 0 if sm.frame == -1 else 100 sm.update(timeout) - calibrator.not_car = sm['carParams'].notCar + calibrator.not_car = sm['carParams'].notCar or TESTING_CLOSET if sm.updated['cameraOdometry']: calibrator.handle_v_ego(sm['carState'].vEgo) From 36a538cb93d23937701b9300cb5aa75d8145f5af Mon Sep 17 00:00:00 2001 From: Quantizr <9859727+Quantizr@users.noreply.github.com> Date: Thu, 12 Sep 2024 22:32:23 -0700 Subject: [PATCH 6/6] make consistent --- system/loggerd/uploader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/loggerd/uploader.py b/system/loggerd/uploader.py index e04cb4bd1e039f..e6de37074f9460 100755 --- a/system/loggerd/uploader.py +++ b/system/loggerd/uploader.py @@ -30,7 +30,7 @@ allow_sleep = bool(os.getenv("UPLOADER_SLEEP", "1")) force_wifi = os.getenv("FORCEWIFI") is not None fake_upload = os.getenv("FAKEUPLOAD") is not None -TESTING_CLOSET = "TESTING_CLOSET" in os.environ +TESTING_CLOSET = os.getenv("TESTING_CLOSET") is not None class FakeRequest: