From a97d078d9528755b9c0cfaf1c13703d6edaa0952 Mon Sep 17 00:00:00 2001 From: Xingdong Zuo Date: Mon, 20 Oct 2025 03:19:57 +0900 Subject: [PATCH] Feat: Support CLI for Launching LeKiwiHost (#1614) * Support CLI for LeKiwiHost Signed-off-by: Xingdong Zuo * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Xingdong Zuo Co-authored-by: Steven Palma --- src/lerobot/robots/lekiwi/lekiwi_host.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/lerobot/robots/lekiwi/lekiwi_host.py b/src/lerobot/robots/lekiwi/lekiwi_host.py index 1155cf71c..ae7ac58c4 100644 --- a/src/lerobot/robots/lekiwi/lekiwi_host.py +++ b/src/lerobot/robots/lekiwi/lekiwi_host.py @@ -18,14 +18,24 @@ import base64 import json import logging import time +from dataclasses import dataclass, field import cv2 +import draccus import zmq from .config_lekiwi import LeKiwiConfig, LeKiwiHostConfig from .lekiwi import LeKiwi +@dataclass +class LeKiwiServerConfig: + """Configuration for the LeKiwi host script.""" + + robot: LeKiwiConfig = field(default_factory=LeKiwiConfig) + host: LeKiwiHostConfig = field(default_factory=LeKiwiHostConfig) + + class LeKiwiHost: def __init__(self, config: LeKiwiHostConfig): self.zmq_context = zmq.Context() @@ -47,17 +57,16 @@ class LeKiwiHost: self.zmq_context.term() -def main(): +@draccus.wrap() +def main(cfg: LeKiwiServerConfig): logging.info("Configuring LeKiwi") - robot_config = LeKiwiConfig() - robot = LeKiwi(robot_config) + robot = LeKiwi(cfg.robot) logging.info("Connecting LeKiwi") robot.connect() logging.info("Starting HostAgent") - host_config = LeKiwiHostConfig() - host = LeKiwiHost(host_config) + host = LeKiwiHost(cfg.host) last_cmd_time = time.time() watchdog_active = False