forked from tangger/lerobot
Feat: Support CLI for Launching LeKiwiHost (#1614)
* Support CLI for LeKiwiHost Signed-off-by: Xingdong Zuo <zuoxingdong@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Xingdong Zuo <zuoxingdong@users.noreply.github.com> Co-authored-by: Steven Palma <imstevenpmwork@ieee.org>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user