-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpider.py
More file actions
60 lines (46 loc) · 1.22 KB
/
Spider.py
File metadata and controls
60 lines (46 loc) · 1.22 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
import math
import thread
from Config import *
import time
from constants import *
class Spider:
walkSpeed = 100.0 / 8.07
rotationSpeed = 180.0 / 10.54
def __init__(self, legs):
self.legs = legs
self.currentDirection = 0.0
self.moving = False
self.turnAngle = 0.0
def init(self):
for l in self.legs:
l.initAtGroundHeight()
def getLegs(self):
return self.legs
def getLeg(self, id):
return self.legs[id]
def initLegsPosition(self, angle, turnAngle = 0.0, incremental = False):
for l in self.legs:
l.clearScheduledMoves()
for i in range(len(self.legs)):
self.legs[i].moveToward()
for l in self.legs:
l.move()
time.sleep(0.5)
for l in self.legs:
l.getCurrentMove().start()
def move(self, startNow = True, turnAngle = 0.0):
self.turnAngle = turnAngle
if startNow:
self.moving = True
while not self.moving:
time.sleep(0.1)
self.initLegsPosition(self.currentDirection, turnAngle = self.turnAngle)
currentTime = 0
while self.moving:
print(time.time() - currentTime)
currentTime = time.time()
time.sleep(0.5)
for l in self.legs:
if not l.hasScheduledMove():
l.moveToward(0, turnAngle = self.turnAngle)
l.move()