From ea4dbc89364155c78d8e2d35d7b7fdcde88854f8 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 9 Aug 2026 21:09:50 -0700 Subject: [PATCH] Remove unused code (#38598) --- openpilot/common/git.py | 9 ----- openpilot/common/stat_live.py | 3 -- .../selfdrive/controls/lib/drive_helpers.py | 1 - openpilot/selfdrive/controls/radard.py | 3 -- openpilot/selfdrive/selfdrived/events.py | 5 --- openpilot/selfdrive/ui/body/animations.py | 19 --------- .../ui/mici/layouts/settings/settings.py | 1 - openpilot/selfdrive/ui/mici/widgets/button.py | 1 - openpilot/selfdrive/ui/mici/widgets/dialog.py | 14 +------ openpilot/system/updated/common.py | 16 -------- tools/scripts/profiling/clpeak/no_print.patch | 39 ------------------- tools/scripts/test_fw_query_on_routes.py | 2 - 12 files changed, 1 insertion(+), 112 deletions(-) delete mode 100644 openpilot/system/updated/common.py delete mode 100644 tools/scripts/profiling/clpeak/no_print.patch diff --git a/openpilot/common/git.py b/openpilot/common/git.py index 6b662e5719..d285116957 100644 --- a/openpilot/common/git.py +++ b/openpilot/common/git.py @@ -31,12 +31,3 @@ def get_origin(cwd: str | None = None) -> str: return run_cmd(["git", "config", "remote." + tracking_remote + ".url"], cwd=cwd) except subprocess.CalledProcessError: # Not on a branch, fallback return run_cmd_default(["git", "config", "--get", "remote.origin.url"], cwd=cwd) - - -@cache -def get_normalized_origin(cwd: str | None = None) -> str: - return get_origin(cwd) \ - .replace("git@", "", 1) \ - .replace(".git", "", 1) \ - .replace("https://", "", 1) \ - .replace(":", "/", 1) diff --git a/openpilot/common/stat_live.py b/openpilot/common/stat_live.py index 3901c448d8..db0919b993 100644 --- a/openpilot/common/stat_live.py +++ b/openpilot/common/stat_live.py @@ -48,9 +48,6 @@ class RunningStat: def std(self): return np.sqrt(self.variance()) - def params_to_save(self): - return [self.M, self.S, self.n] - class RunningStatFilter: def __init__(self, raw_priors=None, filtered_priors=None, max_trackable=-1): self.raw_stat = RunningStat(raw_priors, -1) diff --git a/openpilot/selfdrive/controls/lib/drive_helpers.py b/openpilot/selfdrive/controls/lib/drive_helpers.py index 7ac2f50de0..35ca45e56e 100644 --- a/openpilot/selfdrive/controls/lib/drive_helpers.py +++ b/openpilot/selfdrive/controls/lib/drive_helpers.py @@ -7,7 +7,6 @@ CONTROL_N = 17 CAR_ROTATION_RADIUS = 0.0 # This is a turn radius smaller than most cars can achieve MAX_CURVATURE = 0.2 -MAX_VEL_ERR = 5.0 # m/s MIN_STABLE_DELAY = 0.3 # EU guidelines diff --git a/openpilot/selfdrive/controls/radard.py b/openpilot/selfdrive/controls/radard.py index 30824c07b8..6fecfffb1d 100755 --- a/openpilot/selfdrive/controls/radard.py +++ b/openpilot/selfdrive/controls/radard.py @@ -178,8 +178,6 @@ def get_lead(v_ego: float, ready: bool, tracks: dict[int, Track], lead_msg: capn class RadarD: def __init__(self, delay: float = 0.0): - self.current_time = 0.0 - self.tracks: dict[int, Track] = {} self.kalman_params = KalmanParams(DT_MDL) self.lead_prob_filters = [FirstOrderFilter(0.0, 0.2, DT_MDL) for _ in range(2)] @@ -195,7 +193,6 @@ class RadarD: def update(self, sm: messaging.SubMaster, rr: car.RadarData): self.ready = sm.seen['modelV2'] - self.current_time = 1e-9*max(sm.logMonoTime.values()) if sm.recv_frame['carState'] != self.last_v_ego_frame: self.v_ego = sm['carState'].vEgo diff --git a/openpilot/selfdrive/selfdrived/events.py b/openpilot/selfdrive/selfdrived/events.py index 0464647c3b..2127cdeceb 100755 --- a/openpilot/selfdrive/selfdrived/events.py +++ b/openpilot/selfdrive/selfdrived/events.py @@ -339,11 +339,6 @@ def low_memory_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaste return NormalPermanentAlert("Low Memory", f"{sm['deviceState'].memoryUsagePercent}% used") -def high_cpu_usage_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster, metric: bool, soft_disable_time: int, personality) -> Alert: - x = max(sm['deviceState'].cpuUsagePercent, default=0.) - return NormalPermanentAlert("High CPU Usage", f"{x}% used") - - def modeld_lagging_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster, metric: bool, soft_disable_time: int, personality) -> Alert: return NormalPermanentAlert("Driving Model Lagging", f"{sm['modelV2'].frameDropPerc:.1f}% frames dropped") diff --git a/openpilot/selfdrive/ui/body/animations.py b/openpilot/selfdrive/ui/body/animations.py index 302f8989bf..3aecd52e97 100644 --- a/openpilot/selfdrive/ui/body/animations.py +++ b/openpilot/selfdrive/ui/body/animations.py @@ -87,21 +87,12 @@ BROW_LOWERED = [ (2, 0) ] BROW_STRAIGHT = [(1, 0), (1, 1), (1, 2)] -BROW_DOWN = [ -(0, 1), (0, 2), - (1, 3) -] - # Mouths (centered, not mirrored) MOUTH_SMILE = [ (6, 6), (6, 9), (7, 7), (7, 8), ] MOUTH_NORMAL = [(7, 7), (7, 8)] -MOUTH_SAD = [ - (6, 7), (6, 8), -(7, 6), (7, 9) -] # --- Animations --- @@ -168,16 +159,6 @@ INQUISITIVE = Animation( repeat_interval=10 ) -WINK = Animation( - frames=[ - _make_frame(EYE_OPEN, _mirror(EYE_OPEN), BROW_HIGH, _mirror(BROW_HIGH), MOUTH_SMILE), - _make_frame(EYE_OPEN, _mirror(EYE_CLOSED), BROW_HIGH, _mirror(_shift(BROW_DOWN, (0, 2))), MOUTH_SMILE), - ], - mode=AnimationMode.ONCE_FORWARD_BACKWARD, - frame_duration=0.75, -) - - # --- Face Animator Class --- class FaceAnimator: diff --git a/openpilot/selfdrive/ui/mici/layouts/settings/settings.py b/openpilot/selfdrive/ui/mici/layouts/settings/settings.py index 56a953a65d..eb7789cba9 100644 --- a/openpilot/selfdrive/ui/mici/layouts/settings/settings.py +++ b/openpilot/selfdrive/ui/mici/layouts/settings/settings.py @@ -50,7 +50,6 @@ class SettingsLayout(NavScroller): device_btn, software_btn, PairBigButton(), - #BigDialogButton("manual", "", "icons_mici/settings/manual_icon.png", "Check out the mici user\nmanual at comma.ai/setup"), firehose_btn, developer_btn, ]) diff --git a/openpilot/selfdrive/ui/mici/widgets/button.py b/openpilot/selfdrive/ui/mici/widgets/button.py index dcb1dc2fd0..0ecda6a0c5 100644 --- a/openpilot/selfdrive/ui/mici/widgets/button.py +++ b/openpilot/selfdrive/ui/mici/widgets/button.py @@ -17,7 +17,6 @@ else: except (ImportError, OSError): Params = None -SCROLLING_SPEED_PX_S = 50 COMPLICATION_SIZE = 36 LABEL_COLOR = rl.Color(255, 255, 255, int(255 * 0.9)) COMPLICATION_GREY = rl.Color(0xAA, 0xAA, 0xAA, 255) diff --git a/openpilot/selfdrive/ui/mici/widgets/dialog.py b/openpilot/selfdrive/ui/mici/widgets/dialog.py index ed1466449b..77dfa3cb97 100644 --- a/openpilot/selfdrive/ui/mici/widgets/dialog.py +++ b/openpilot/selfdrive/ui/mici/widgets/dialog.py @@ -10,7 +10,7 @@ from openpilot.system.ui.lib.text_measure import measure_text_cached from openpilot.system.ui.lib.application import gui_app, FontWeight, MousePos from openpilot.system.ui.widgets.slider import RedBigSlider, BigSlider from openpilot.common.filter_simple import FirstOrderFilter -from openpilot.selfdrive.ui.mici.widgets.button import BigCircleButton, BigButton, GreyBigButton +from openpilot.selfdrive.ui.mici.widgets.button import BigCircleButton, GreyBigButton DEBUG = False @@ -216,18 +216,6 @@ class BigInputDialog(BigDialogBase): self._confirm_callback() -class BigDialogButton(BigButton): - def __init__(self, text: str, value: str = "", icon: Union[str, rl.Texture] = "", description: str = ""): - super().__init__(text, value, icon) - self._description = description - - def _handle_mouse_release(self, mouse_pos: MousePos): - super()._handle_mouse_release(mouse_pos) - - dlg = BigDialog(self.text, self._description) - gui_app.push_widget(dlg) - - class BigConfirmationCircleButton(BigCircleButton): def __init__(self, title: str, icon: rl.Texture, confirm_callback: Callable[[], None], exit_on_confirm: bool = True, red: bool = False, icon_offset: tuple[int, int] = (0, 0)): diff --git a/openpilot/system/updated/common.py b/openpilot/system/updated/common.py deleted file mode 100644 index 6bb745f6b0..0000000000 --- a/openpilot/system/updated/common.py +++ /dev/null @@ -1,16 +0,0 @@ -import os -import pathlib - - -def get_consistent_flag(path: str) -> bool: - consistent_file = pathlib.Path(os.path.join(path, ".overlay_consistent")) - return consistent_file.is_file() - -def set_consistent_flag(path: str, consistent: bool) -> None: - os.sync() - consistent_file = pathlib.Path(os.path.join(path, ".overlay_consistent")) - if consistent: - consistent_file.touch() - elif not consistent: - consistent_file.unlink(missing_ok=True) - os.sync() diff --git a/tools/scripts/profiling/clpeak/no_print.patch b/tools/scripts/profiling/clpeak/no_print.patch deleted file mode 100644 index 44a5efd10f..0000000000 --- a/tools/scripts/profiling/clpeak/no_print.patch +++ /dev/null @@ -1,39 +0,0 @@ -diff --git a/src/logger.cpp b/src/logger.cpp -index a63c6dd..a1d9860 100644 ---- a/src/logger.cpp -+++ b/src/logger.cpp -@@ -24,34 +24,22 @@ logger::~logger() - - void logger::print(string str) - { -- cout << str; -- cout.flush(); - } - - void logger::print(double val) - { -- cout << setprecision(2) << fixed; -- cout << val; -- cout.flush(); - } - - void logger::print(float val) - { -- cout << setprecision(2) << fixed; -- cout << val; -- cout.flush(); - } - - void logger::print(int val) - { -- cout << val; -- cout.flush(); - } - - void logger::print(unsigned int val) - { -- cout << val; -- cout.flush(); - } - - void logger::xmlOpenTag(string tag) diff --git a/tools/scripts/test_fw_query_on_routes.py b/tools/scripts/test_fw_query_on_routes.py index ab539e4feb..33e1aa39ba 100755 --- a/tools/scripts/test_fw_query_on_routes.py +++ b/tools/scripts/test_fw_query_on_routes.py @@ -12,7 +12,6 @@ from openpilot.tools.lib.logreader import LogReader, ReadMode from openpilot.tools.lib.route import SegmentRange -NO_API = "NO_API" in os.environ SUPPORTED_BRANDS = VERSIONS.keys() SUPPORTED_CARS = [brand for brand in SUPPORTED_BRANDS for brand in interface_names[brand]] UNKNOWN_BRAND = "unknown" @@ -178,4 +177,3 @@ if __name__ == "__main__": print(f"Correct fuzzy matches: {good_fuzzy}") print(f"Wrong fuzzy matches: {wrong_fuzzy}") print() -