From 49918efbc1946da822f743902ba36da8e1e398b4 Mon Sep 17 00:00:00 2001 From: Steven Palma Date: Fri, 26 Sep 2025 14:30:17 +0200 Subject: [PATCH] chore(utils): remove unused code (#2059) --- src/lerobot/utils/control_utils.py | 59 ------------------------------ src/lerobot/utils/import_utils.py | 4 -- 2 files changed, 63 deletions(-) diff --git a/src/lerobot/utils/control_utils.py b/src/lerobot/utils/control_utils.py index 47beb574..17371921 100644 --- a/src/lerobot/utils/control_utils.py +++ b/src/lerobot/utils/control_utils.py @@ -27,7 +27,6 @@ from typing import Any import numpy as np import torch from deepdiff import DeepDiff -from termcolor import colored from lerobot.datasets.lerobot_dataset import LeRobotDataset from lerobot.datasets.utils import DEFAULT_FEATURES @@ -36,64 +35,6 @@ from lerobot.processor import PolicyAction, PolicyProcessorPipeline from lerobot.robots import Robot -def log_control_info(robot: Robot, dt_s, episode_index=None, frame_index=None, fps=None): - """ - Logs performance metrics for a single step of the robot control loop. - - This function formats and prints a single line of log information, including episode/frame counters, - total loop time (dt), and detailed timings for various robot and camera operations. It can also - highlight performance drops in yellow if the actual FPS is lower than the target FPS. - - Args: - robot: The `Robot` instance, used to access its internal logs for detailed timings. - dt_s: The total duration of the control loop step in seconds. - episode_index: The index of the current episode. - frame_index: The index of the current frame within the episode. - fps: The target frames per second, used to check for performance degradation. - """ - log_items = [] - if episode_index is not None: - log_items.append(f"ep:{episode_index}") - if frame_index is not None: - log_items.append(f"frame:{frame_index}") - - def log_dt(shortname, dt_val_s): - nonlocal log_items, fps - info_str = f"{shortname}:{dt_val_s * 1000:5.2f} ({1 / dt_val_s:3.1f}hz)" - if fps is not None: - actual_fps = 1 / dt_val_s - if actual_fps < fps - 1: - info_str = colored(info_str, "yellow") - log_items.append(info_str) - - # total step time displayed in milliseconds and its frequency - log_dt("dt", dt_s) - - # TODO(aliberts): move robot-specific logs logic in robot.print_logs() - if not robot.robot_type.startswith("stretch"): - for name in robot.leader_arms: - key = f"read_leader_{name}_pos_dt_s" - if key in robot.logs: - log_dt("dtRlead", robot.logs[key]) - - for name in robot.follower_arms: - key = f"write_follower_{name}_goal_pos_dt_s" - if key in robot.logs: - log_dt("dtWfoll", robot.logs[key]) - - key = f"read_follower_{name}_pos_dt_s" - if key in robot.logs: - log_dt("dtRfoll", robot.logs[key]) - - for name in robot.cameras: - key = f"read_camera_{name}_dt_s" - if key in robot.logs: - log_dt(f"dtR{name}", robot.logs[key]) - - info_str = " ".join(log_items) - logging.info(info_str) - - @cache def is_headless(): """ diff --git a/src/lerobot/utils/import_utils.py b/src/lerobot/utils/import_utils.py index 09e64937..5f41ea3a 100644 --- a/src/lerobot/utils/import_utils.py +++ b/src/lerobot/utils/import_utils.py @@ -57,8 +57,4 @@ def is_package_available(pkg_name: str, return_version: bool = False) -> tuple[b return package_exists -_torch_available, _torch_version = is_package_available("torch", return_version=True) _transformers_available = is_package_available("transformers") -_gym_xarm_available = is_package_available("gym_xarm") -_gym_aloha_available = is_package_available("gym_aloha") -_gym_pusht_available = is_package_available("gym_pusht")