forked from greymatterrobotics/banshee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfans.py
57 lines (44 loc) · 927 Bytes
/
fans.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
55
56
57
# Fans
# Handles all the fan shit like moving and blowing
from banshee import *
from time import sleep
class Fans:
def __init__(self):
self.r = Banshee()
# Init ESC
self.r.power._set_motor_rail(False)
sleep(0.5)
self.all_off()
self.r.power._set_motor_rail(True)
sleep(6)
print "Init fans"
# Motor helpers
def off(self, motor):
self.r.servos[0][motor] = 53
def all_off(self):
for i in range(5):
self.off(i)
def blow(self, motors):
for i in motors:
sleep(0.1)
self.r.servos[0][i] = 59
def suck(self, motors):
for i in motors:
self.r.servos[0][i] = 47
# Movement helpers
def forwards(self):
self.blow([0, 1])
self.suck([2, 3])
def backwards(self):
self.blow([2, 3])
self.suck([0, 1])
def spin(self):
self.blow(range(4))
def stop(self):
self.all_off()
# Lift helpers
def lift(self):
self.r.servos[0][4] = 61
sleep(0.5)
def drop(self):
self.off(4)