-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRobotController.py
54 lines (42 loc) · 1.5 KB
/
RobotController.py
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
import time
from math import sin, pi
from utilities.kinematics import Kinematic
import numpy as np
#Input parameters
stanceTime = 1000
swingTime = 500
maxStanceDist = 2
#Internal variables
contact = [[1,1,1,1],
[1,0,0,1],
[1,1,1,1],
[0,1,1,0]]
t0=0
P = [[0,0,0],[0,0,0]]
#Controller input
move = 1
yStanceDist = 150
control = Kinematic
while True:
for i in range(2):
if move:
if t0 == 0:
t0 = time.time()*1000
dt = (time.time()*1000-t0 + i*(stanceTime+swingTime)/2)%(stanceTime+swingTime)
if dt >= 0 and dt < stanceTime:
P[i][0]=(stanceTime/2-dt)*yStanceDist/stanceTime
P[i][1]=0
if dt >= stanceTime and dt < swingTime+stanceTime:
P[i][0]=-yStanceDist/2 + (dt-stanceTime)*yStanceDist/swingTime
P[i][1]=yStanceDist/2.3*sin((dt-stanceTime)*pi/swingTime)
print(P)
Lp=np.array([[P[0][0],P[0][1],P[0][2],0],[P[1][0],P[1][1],P[1][2],0],[P[1][0],P[1][1],P[1][2],0],[P[0][0],P[0][1],P[0][2],0]])
Kinematic().setRobot(Lp,(0,0,0),(0,0,0))
"""
if dt >= 0 and dt < ((stanceTime-swingTime)/2):
P[0]=-(dt+swingTime/2)*yStanceDist/stanceTime
if dt >= ((stanceTime-swingTime)/2) and dt < ((stanceTime+swingTime)/2):
P[0]=(dt-stanceTime/2)*yStanceDist/swingTime
if dt >= ((stanceTime+swingTime)/2) and dt < stanceTime:
if dt >= stanceTime and dt < (stanceTime+swingTime):
"""