Files
lerobot_aloha/collect_data/rosrobot_factory.py
2025-04-05 21:46:49 +08:00

27 lines
807 B
Python

import yaml
import argparse
from typing import Dict, List, Any, Optional
from rosrobot import Robot
from agilex_robot import AgilexRobot
class RobotFactory:
@staticmethod
def create(config_file: str, args: Optional[argparse.Namespace] = None) -> Robot:
"""
根据配置文件自动创建合适的机器人实例
Args:
config_file: 配置文件路径
args: 运行时参数
"""
with open(config_file, 'r') as f:
config = yaml.safe_load(f)
robot_type = config.get('robot_type', 'agilex')
if robot_type == 'agilex':
return AgilexRobot(config_file, args)
# 可扩展其他机器人类型
else:
raise ValueError(f"Unsupported robot type: {robot_type}")