-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_body_rotation.py
More file actions
70 lines (55 loc) · 1.53 KB
/
test_body_rotation.py
File metadata and controls
70 lines (55 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
"""Reachy Mini 底座旋转演示
body_yaw: 控制身体/底座偏航角,范围 ±160 度
"""
import requests
import time
import sys
from pathlib import Path
# 添加上级目录到路径以导入配置模块
sys.path.insert(0, str(Path(__file__).parent.parent))
from config_loader import get_config
def rotate_base(count=3):
"""底座左右旋转
Args:
count: 旋转次数
"""
config = get_config()
base_url = config.base_url
print("=" * 50)
print("Reachy Mini 底座旋转演示")
print("=" * 50)
# 启用电机
print("\n启用电机...")
requests.post(f"{base_url}/motors/set_mode/enabled")
time.sleep(1)
# 底座旋转
print(f"\n🔄 底座旋转 {count} 次...")
for i in range(count):
print(f" 第 {i+1} 次: 左转 -> 右转")
# 底座左转
requests.post(f"{base_url}/move/goto", json={
"body_yaw": 30,
"duration": 1.0,
"interpolation": "minjerk"
})
time.sleep(1.5)
# 底座右转
requests.post(f"{base_url}/move/goto", json={
"body_yaw": -30,
"duration": 1.0,
"interpolation": "minjerk"
})
time.sleep(1.5)
# 回正
print("\n回到原位...")
requests.post(f"{base_url}/move/goto", json={
"body_yaw": 0,
"duration": 1.0,
"interpolation": "minjerk"
})
print("\n" + "=" * 50)
print("完成!")
print("=" * 50)
if __name__ == "__main__":
rotate_base(3)