-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTank.py
72 lines (49 loc) · 1.77 KB
/
Tank.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
'''
This file is part of BalgassZord.
BalgassZord is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
BalgassZord is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with BalgassZord. If not, see <http://www.gnu.org/licenses/>.
'''
from Tank.Control.Joystick import Joystick
from Tank.Control.OpenCVClassifier import OpenCVClassifier
from Tank.Caterpillar import Caterpillar
from Tank.Arm import Arm
from time import time,sleep
class Tank():
def __init__(self):
self.cycling = True
self.cycletime = 0.2
self.__setup()
self.__baton()
def __setup(self):
self.__control = OpenCVClassifier()
self.__caterpillar = Caterpillar(True)
self.__arm = Arm(True)
def __baton(self):
initialTime = time()
while self.cycling:
self.__loop()
waitTime = time() - initialTime
if waitTime < self.cycletime:
sleep(self.cycletime - waitTime)
initialTime = time()
def __loop(self):
self.__control.refresh()
axisLeft = self.__control.getAxisLeft()
axisRight = self.__control.getAxisRight()
print axisRight
self.__caterpillar.setDirection(axisLeft)
self.__arm.setDirection(axisRight)
return
print "BalgassZord Copyright (C) 2017-2018 Leandro Galo Ortega"
print "This program comes with ABSOLUTELY NO WARRANTY."
print "This is free software, and you are welcome to redistribute it"
sleep(5)
Tank()