-
Notifications
You must be signed in to change notification settings - Fork 15
/
robot.py
47 lines (28 loc) · 1.56 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
#This is where your main robot code resides. It extendeds from the BrickPi Interface File
#It includes all the code inside brickpiinterface. The CurrentCommand and CurrentRoutine are important because they can keep track of robot functions and commands. Remember Flask is using Threading (e.g. more than once process which can confuse the robot)
from interfaces.brickpiinterface import *
import global_vars as GLOBALS
import logging
class Robot(BrickPiInterface):
def __init__(self, timelimit=10, logger=logging.getLogger()):
super().__init__(timelimit, logger)
self.CurrentCommand = "stop" #use this to stop or start functions
self.CurrentRoutine = "stop" #use this stop or start routines
return
#Create a function to move time and power which will stop if colour is detected or wall has been found
#Create a function to search for victim
#Create a routine that will effective search the maze and keep track of where the robot has been.
# Only execute if this is the main file, good for testing code
if __name__ == '__main__':
logging.basicConfig(filename='logs/robot.log', level=logging.INFO)
ROBOT = Robot(timelimit=10) #10 second timelimit before
bp = ROBOT.BP
ROBOT.configure_sensors() #This takes 4 seconds
ROBOT.rotate_power_degrees_IMU(20,-90)
start = time.time()
limit = start + 10
while (time.time() < limit):
compass = ROBOT.get_compass_IMU()
print(compass)
sensordict = ROBOT.get_all_sensors()
ROBOT.safe_exit()