-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_stance.py
More file actions
57 lines (44 loc) · 1.37 KB
/
test_stance.py
File metadata and controls
57 lines (44 loc) · 1.37 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
import time
import numpy as np
import math
import sys
import os
from inverse_kinematics.inverse_kinematics_controller import InverseKinematicsController
from wrapper import Wrapper
def transition(cur, new):
traj = np.linspace(np.array(cur), np.array(new), 200)
cur_time = time.time()
count = 0
while count < 200:
wrapper.update(traj[count])
if time.time() - cur_time > 0.005:
count += 1
cur_time = time.time()
wrapper = Wrapper()
stand = [0, 0.75, -1.8, 0, 0.75, -1.8, 0, 0.75, -1.8, 0, 0.75, -1.8]
sit = [-0.1, 1.5, -2.5, 0.1, 1.5, -2.5, -0.4, 1.5, -2.5, 0.4, 1.5, -2.5]
stable_stance = [
0.5, 0.7, -1.5, 0.5, 0.7, -1.2, -0.5, 0.7, -1.5, -0.5, 0.7, -1.2
]
# stable_stance = [
# 0.2, 0.7, -1.5, 0.5, 0.5, -1.5, -0.2, 0.7, -1.5, -0.5, 0.5, -1.5
# ]
# put the robot in sitting stance
wrapper.update(sit)
# stand up
transition(sit, stand)
action = stable_stance
sim_order = ["FL", "BL", "FR", "BR"]
try:
while True:
wrapper.update(stable_stance, input_order=sim_order)
except KeyboardInterrupt:
transition(wrapper.map(action, sim_order, wrapper.order), stand)
transition(stand, sit)
except Exception as e:
print(e)
transition(wrapper.map(action, sim_order, wrapper.order), stand)
transition(stand, sit)
print("lock in SIT mode, keyboard interrupt to stop")
while True:
wrapper.update(sit)