一、概述
1、Lerobot:LeRobot 旨在为 PyTorch 中的真实机器人技术提供模型、数据集和工具
-
最顶层:scripts (命令行工具),属于发号施令层
-
中间层:common/policies (控制策略),属于中间执行层
-
底层支撑层:common/datasets, common/envs, common/robot_devices
-
基础配置层: configs, common/utils
2、So 100: 2个6关节的机械臂,主臂遥操作从臂
二、安装配置
1、安装Lerobot & SO 100
conda create -y -n lerobot python=3.10
conda activate lerobot
git clone https://github.com/huggingface/lerobot.git ~/lerobot
conda install ffmpeg -c conda-forge
cd ~/lerobot && pip install -e ".[feetech]"
2、配置SO 100
-
找到与每个手臂关联的 USB 端口并更新配置文件
@RobotConfig.register_subclass("so100")
@dataclass
class So100RobotConfig(ManipulatorRobotConfig):
calibration_dir: str = ".cache/calibration/so100"
# `max_relative_target` limits the magnitude of the relative positional target vector for safety purposes.
# Set this to a positive scalar to have the same value for all motors, or a list that is the same length as
# the number of motors in your follower arms.
max_relative_target: int | None = None
leader_arms: dict[str, MotorsBusConfig] = field(
default_factory=lambda: {
"main": FeetechMotorsBusConfig(
port="/dev/tty.usbmodem58760431091", <-- UPDATE HERE
motors={
# name: (index, model)
"shoulder_pan": [1, "sts3215"],
"shoulder_lift": [2, "sts3215"],
"elbow_flex": [3, "sts3215"],
"wrist_flex": [4, "sts3215"],
"wrist_roll": [5, "sts3215"],
"gripper": [6, "sts3215"],
},
),
}
)
follower_arms: dict[str, MotorsBusConfig] = field(
default_factory=lambda: {
"main": FeetechMotorsBusConfig(
port="/dev/tty.usbmodem585A0076891", <-- UPDATE HERE
motors={
# name: (index, model)
"shoulder_pan": [1, "sts3215"],
"shoulder_lift": [2, "sts3215"],
"elbow_flex": [3, "sts3215"],
"wrist_flex": [4, "sts3215"],
"wrist_roll": [5, "sts3215"],
"gripper": [6, "sts3215"],
},
),
}
)
-
配置12个舵机
-
手臂校准
三、使用
1、记录数据集
python lerobot/scripts/control_robot.py \
--robot.type=so100 \
--control.type=record \
--control.fps=30 \
--control.single_task="Grasp a lego block and put it in the bin." \
--control.repo_id=lerobot/so100_test \
--control.tags='["so100","tutorial"]' \
--control.warmup_time_s=5 \
--control.episode_time_s=30 \
--control.reset_time_s=30 \
--control.num_episodes=2 \
--control.push_to_hub=false
# 在此数据上继续采集
--control.resume=true
-
核心参数
-
repo_id:数据集名称,默认路径 ~/.cache/huggingface/lerobot;可通过环境变量HF_LEROBOT_HOME修改
-
reset_time_s:录制一集的最大时长
-
reset_time_s:场景重置时间
-
num_episodes:录制多少集
-
-
录制技巧
-
-> 提前退出,保存当前集,并重置环境
-
<- 提前退出,丢弃当前集,并重置环境
-
eac 保存当前集,并结束采集
-
-
合并多个数据集
2、可视化数据集
python lerobot/scripts/visualize_dataset_html.py \
--repo-id lerobot/so100_test \
--local-files-only 1
3、重播
python lerobot/scripts/control_robot.py \
--robot.type=so100 \
--control.type=replay \
--control.fps=30 \
--control.repo_id=lerobot/so100_test \
--control.episode=0
4、训练
python lerobot/scripts/train.py \
--dataset.repo_id=lerobot/so100_test \
--policy.type=act \
--output_dir=outputs/train/act_so100_test \
--job_name=act_so100_test \
--policy.device=cuda \
--wandb.enable=true
5、推理
python lerobot/scripts/control_robot.py \
--robot.type=so100 \
--control.type=record \
--control.fps=30 \
--control.single_task="Grasp a lego block and put it in the bin." \
--control.repo_id=lerobot/eval_act_so100_test \
--control.tags='["tutorial"]' \
--control.warmup_time_s=5 \
--control.episode_time_s=30 \
--control.reset_time_s=30 \
--control.num_episodes=10 \
--control.push_to_hub=true \
--control.policy.path=outputs/train/act_so100_test/checkpoints/last/pretrained_model