| import threading
|
|
|
| from lerobot.async_inference.configs import RobotClientConfig
|
| from lerobot.async_inference.helpers import visualize_action_queue_size
|
| from lerobot.async_inference.robot_client import RobotClient
|
| from lerobot.cameras.opencv.configuration_opencv import OpenCVCameraConfig
|
| from lerobot.robots.so100_follower import SO100FollowerConfig
|
|
|
|
|
|
|
| camera_cfg = {
|
| "up": OpenCVCameraConfig(index_or_path=0, width=640, height=480, fps=30),
|
| "side": OpenCVCameraConfig(index_or_path=1, width=640, height=480, fps=30),
|
| }
|
|
|
|
|
| follower_port = ...
|
|
|
|
|
| follower_id = ...
|
|
|
| robot_cfg = SO100FollowerConfig(port=follower_port, id=follower_id, cameras=camera_cfg)
|
|
|
| server_address = ...
|
|
|
|
|
| client_cfg = RobotClientConfig(
|
| robot=robot_cfg,
|
| server_address=server_address,
|
| policy_device="mps",
|
| policy_type="act",
|
| pretrained_name_or_path="fracapuano/robot_learning_tutorial_act",
|
| chunk_size_threshold=0.5,
|
| actions_per_chunk=50,
|
| )
|
|
|
|
|
| client = RobotClient(client_cfg)
|
|
|
|
|
| task = ...
|
|
|
| if client.start():
|
|
|
| action_receiver_thread = threading.Thread(target=client.receive_actions, daemon=True)
|
| action_receiver_thread.start()
|
|
|
| try:
|
|
|
| client.control_loop(task)
|
| except KeyboardInterrupt:
|
| client.stop()
|
| action_receiver_thread.join()
|
|
|
| visualize_action_queue_size(client.action_queue_size)
|
|
|