-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrobot.py
59 lines (38 loc) · 1.25 KB
/
robot.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
#!/usr/bin/env python
import time
from buildhat import Motor
# Software Limitatons ~ Spooky!
SPEED = 20
MAX_RIGHT = 90 # POSITION VS DEGREE
MAX_LEFT = -90
MAX_UP = 80
HEAD_POS = 10
MAX_DOWN = -10
class Robot:
def __init__(self):
print(f"setting up robot")
self.flippy = 1
self.x = Motor('C')
self.y = Motor('D')
print(f"Motor X Connected? : {self.x.connected}")
print(f"Motor Y Connected? : {self.y.connected}")
self.x.set_default_speed(SPEED)
self.y.set_default_speed(SPEED)
print("DONE")
# def __del__(self):
# print("i am being destroyed, goodbye cruel world")
def Patrol(self):
self.x.run_to_position(MAX_RIGHT)
self.x.run_to_position(MAX_LEFT)
def MotorHandlerX(self,speed, pos, apos): # MIGHT BE TRASH?
print(f"MOTOR X position: {pos}\t")
if pos > 90 or pos < -90:
self.x.stop()
print("MOTOR X STOPPED! TOO FAR!")
def MotorHandlerY(self,speed, pos, apos):
print(f"MOTOR Y position: {pos}\t")
if pos > 45 or pos < -10:
self.y.stop()
print("MOTOR Y STOPPED! TOO FAR!")
def GetPositions(self):
return [self.x.get_position(),self.y.get_position()]