Add simple manual mode script and uv lock
This commit is contained in:
parent
e492233348
commit
4dfed85048
17
README_ZH.md
17
README_ZH.md
@ -157,7 +157,17 @@ uf-robot-teleop --config_path path/to/config.yaml --fps 60 # 指定频率
|
||||
uf-robot-teleop --config_path config/umi/xarm6_umi_record_config.yaml
|
||||
```
|
||||
|
||||
### 2. 数据采集
|
||||
### 2. xArm 人工拖拽模式测试
|
||||
|
||||
使用 xArm 的关节示教模式(`mode=2`)进行人工拖拽:
|
||||
|
||||
```bash
|
||||
uf-xarm-manual-mode --config_path config/manual_mode/xarm_manual_mode_config.yaml
|
||||
```
|
||||
|
||||
配置中的 `manual_mode` 为 `true` 时进入拖拽模式,按回车后恢复为普通模式;设置为 `false` 可直接恢复为普通模式。
|
||||
|
||||
### 3. 数据采集
|
||||
|
||||
通过遥操作录制数据集。
|
||||
|
||||
@ -170,7 +180,7 @@ uf-lerobot-record --config_path path/to/config.yaml --resume true # 续录
|
||||
uf-lerobot-record --config_path config/umi/xarm6_umi_record_config.yaml
|
||||
```
|
||||
|
||||
### 3. Lerobot训练
|
||||
### 4. Lerobot训练
|
||||
|
||||
采集数据后,使用 LeRobot 训练管道进行模仿学习训练。
|
||||
|
||||
@ -198,7 +208,7 @@ lerobot-train \
|
||||
--save_freq=20000
|
||||
```
|
||||
|
||||
### 4. 推理
|
||||
### 5. 推理
|
||||
|
||||
指定模型进行推理
|
||||
|
||||
@ -312,4 +322,3 @@ lerobot_robot_ufactory/
|
||||
## 许可证
|
||||
|
||||
本项目基于 Apache License 2.0 发布,详见 [LICENSE](LICENSE) 文件。
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ robot:
|
||||
id: "uf_robot"
|
||||
robot_dof: 5
|
||||
control_space: "joint"
|
||||
robot_ip: "192.168.1.75"
|
||||
robot_ip: "192.168.1.245"
|
||||
gripper_type: 1
|
||||
start_joints: [0, 0, -90, 90, 0]
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ robot:
|
||||
id: "uf_robot"
|
||||
robot_dof: 6
|
||||
control_space: "joint"
|
||||
robot_ip: "192.168.1.68"
|
||||
robot_ip: "192.168.1.245"
|
||||
gripper_type: 1
|
||||
start_joints: [0, 0, -90, 0, 90, 0]
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ robot:
|
||||
id: "uf_robot"
|
||||
robot_dof: 7
|
||||
control_space: "joint"
|
||||
robot_ip: "192.168.1.85"
|
||||
robot_ip: "192.168.1.245"
|
||||
gripper_type: 1
|
||||
start_joints: [0, 0, 0, 90, 0, 90, 0]
|
||||
|
||||
|
||||
8
config/manual_mode/xarm_manual_mode_config.yaml
Normal file
8
config/manual_mode/xarm_manual_mode_config.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
# xArm manual/joint teaching mode test configuration.
|
||||
robot_ip: "192.168.1.245"
|
||||
|
||||
# true: enter mode 2 and wait for Enter; false: restore mode 0.
|
||||
manual_mode: true
|
||||
|
||||
# xArm teach sensitivity, valid range: 1-5.
|
||||
teach_sensitivity: 3
|
||||
@ -34,6 +34,7 @@ dependencies = [
|
||||
[project.scripts]
|
||||
uf-robot-teleop = "lerobot_robot_ufactory.scripts.uf_robot_teleop:main"
|
||||
uf-lerobot-record = "lerobot_robot_ufactory.scripts.uf_lerobot_record:main"
|
||||
uf-xarm-manual-mode = "lerobot_robot_ufactory.scripts.uf_xarm_manual_mode:main"
|
||||
uf-lerobot-eval = "lerobot_robot_ufactory.scripts.uf_lerobot_eval:main"
|
||||
uf-vive-calibrate = "lerobot_robot_ufactory.scripts.vive_calibrate:main"
|
||||
uf-camera-view = "lerobot_robot_ufactory.scripts.uf_camera_view:main"
|
||||
|
||||
78
src/lerobot_robot_ufactory/scripts/uf_xarm_manual_mode.py
Normal file
78
src/lerobot_robot_ufactory/scripts/uf_xarm_manual_mode.py
Normal file
@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
|
||||
import lerobot_robot_ufactory # noqa: F401 # register UFACTORY plugins
|
||||
from xarm.wrapper import XArmAPI
|
||||
from lerobot_robot_ufactory.configs import parser as config_parser
|
||||
|
||||
|
||||
@dataclass
|
||||
class ManualModeConfig:
|
||||
robot_ip: str = "192.168.1.127"
|
||||
manual_mode: bool = True
|
||||
teach_sensitivity: int | None = 3
|
||||
|
||||
|
||||
@config_parser.wrap()
|
||||
def get_cfg(cfg: ManualModeConfig) -> ManualModeConfig:
|
||||
return cfg
|
||||
|
||||
|
||||
def run(cfg: ManualModeConfig):
|
||||
if cfg.teach_sensitivity is not None and not 1 <= cfg.teach_sensitivity <= 5:
|
||||
raise ValueError("teach_sensitivity must be between 1 and 5")
|
||||
|
||||
arm = XArmAPI(cfg.robot_ip)
|
||||
try:
|
||||
if not arm.connected:
|
||||
raise ConnectionError(f"Failed to connect to xArm at {cfg.robot_ip}")
|
||||
|
||||
arm.motion_enable(enable=True)
|
||||
arm.clean_error()
|
||||
arm.set_mode(0)
|
||||
arm.set_state(0)
|
||||
|
||||
if cfg.manual_mode:
|
||||
if cfg.teach_sensitivity is not None:
|
||||
code = arm.set_teach_sensitivity(cfg.teach_sensitivity)
|
||||
if code != 0:
|
||||
raise RuntimeError(f"set_teach_sensitivity failed, code={code}")
|
||||
|
||||
code = arm.set_mode(2)
|
||||
if code != 0:
|
||||
raise RuntimeError(f"set_mode(2) failed, code={code}")
|
||||
code = arm.set_state(0)
|
||||
if code != 0:
|
||||
raise RuntimeError(f"set_state(0) failed, code={code}")
|
||||
|
||||
print("Joint teaching mode enabled. Drag the arm manually.")
|
||||
input("Press Enter to disable mode 2... ")
|
||||
else:
|
||||
code = arm.set_mode(0)
|
||||
if code != 0:
|
||||
raise RuntimeError(f"set_mode(0) failed, code={code}")
|
||||
code = arm.set_state(0)
|
||||
if code != 0:
|
||||
raise RuntimeError(f"set_state(0) failed, code={code}")
|
||||
print("Joint teaching mode disabled.")
|
||||
finally:
|
||||
if arm.connected:
|
||||
# Always leave the robot in normal position-control mode.
|
||||
arm.set_mode(0)
|
||||
arm.set_state(0)
|
||||
arm.disconnect()
|
||||
|
||||
|
||||
def main():
|
||||
cli_parser = argparse.ArgumentParser(description="Control xArm joint teaching mode from YAML")
|
||||
_, unknown = cli_parser.parse_known_args()
|
||||
sys.argv = [sys.argv[0]] + unknown
|
||||
cfg = get_cfg()
|
||||
run(cfg)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in New Issue
Block a user