From 8af693548e3afc82f74818ed7a20abc117236592 Mon Sep 17 00:00:00 2001 From: Daniel Ritchie Date: Fri, 22 Nov 2024 11:14:25 -0700 Subject: [PATCH 1/3] Add support for Windows (#494) --- lerobot/scripts/find_motors_bus_port.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lerobot/scripts/find_motors_bus_port.py b/lerobot/scripts/find_motors_bus_port.py index 51ef6d41c..67b92ad7d 100644 --- a/lerobot/scripts/find_motors_bus_port.py +++ b/lerobot/scripts/find_motors_bus_port.py @@ -1,30 +1,36 @@ +import os import time from pathlib import Path +from serial.tools import list_ports # Part of pyserial library + def find_available_ports(): - ports = [] - for path in Path("/dev").glob("tty*"): - ports.append(str(path)) + if os.name == "nt": # Windows + # List COM ports using pyserial + ports = [port.device for port in list_ports.comports()] + else: # Linux/macOS + # List /dev/tty* ports for Unix-based systems + ports = [str(path) for path in Path("/dev").glob("tty*")] return ports def find_port(): print("Finding all available ports for the MotorsBus.") ports_before = find_available_ports() - print(ports_before) + print("Ports before disconnecting:", ports_before) - print("Remove the usb cable from your MotorsBus and press Enter when done.") - input() + print("Remove the USB cable from your MotorsBus and press Enter when done.") + input() # Wait for user to disconnect the device - time.sleep(0.5) + time.sleep(0.5) # Allow some time for port to be released ports_after = find_available_ports() ports_diff = list(set(ports_before) - set(ports_after)) if len(ports_diff) == 1: port = ports_diff[0] print(f"The port of this MotorsBus is '{port}'") - print("Reconnect the usb cable.") + print("Reconnect the USB cable.") elif len(ports_diff) == 0: raise OSError(f"Could not detect the port. No difference was found ({ports_diff}).") else: @@ -32,5 +38,5 @@ def find_port(): if __name__ == "__main__": - # Helper to find the usb port associated to all your MotorsBus. + # Helper to find the USB port associated with your MotorsBus. find_port() From 20f466768e88c6c68f8232b6d52ca9627fffe814 Mon Sep 17 00:00:00 2001 From: resolver101757 Date: Fri, 22 Nov 2024 18:15:58 +0000 Subject: [PATCH 2/3] bug causes error uploading to huggingface, unicode issue on windows. (#450) From 975c1c25c34d47a359d7abcb0153f41c1d4f297a Mon Sep 17 00:00:00 2001 From: Jannik Grothusen <56967823+J4nn1K@users.noreply.github.com> Date: Fri, 22 Nov 2024 19:19:57 +0100 Subject: [PATCH 3/3] Add distinction between two unallowed cases in name check "eval_" (#489) --- lerobot/common/robot_devices/control_utils.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lerobot/common/robot_devices/control_utils.py b/lerobot/common/robot_devices/control_utils.py index 08bcec2e6..d2879c960 100644 --- a/lerobot/common/robot_devices/control_utils.py +++ b/lerobot/common/robot_devices/control_utils.py @@ -324,7 +324,15 @@ def sanity_check_dataset_name(repo_id, policy): _, dataset_name = repo_id.split("/") # either repo_id doesnt start with "eval_" and there is no policy # or repo_id starts with "eval_" and there is a policy - if dataset_name.startswith("eval_") == (policy is None): + + # Check if dataset_name starts with "eval_" but policy is missing + if dataset_name.startswith("eval_") and policy is None: + raise ValueError( + f"Your dataset name begins with 'eval_' ({dataset_name}), but no policy is provided." + ) + + # Check if dataset_name does not start with "eval_" but policy is provided + if not dataset_name.startswith("eval_") and policy is not None: raise ValueError( - f"Your dataset name begins by 'eval_' ({dataset_name}) but no policy is provided ({policy})." + f"Your dataset name does not begin with 'eval_' ({dataset_name}), but a policy is provided ({policy})." )