-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStats.py
More file actions
90 lines (45 loc) · 1.79 KB
/
Copy pathStats.py
File metadata and controls
90 lines (45 loc) · 1.79 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
##### Stats ######
import math
from sr.robot import *
import sys
import time
start_time = time.time()
print("--- %s seconds ---" % (time.time() - start_time))
counter = 0
laps = " "
dist_right = " "
dist_left = " "
file_laps = open("laps.txt","w")
l = open("dist_left.txt","w")
r = open("dist_right.txt","w")
def Lap_Counter(Grab):
global counter, laps
if Grab:
counter = counter + 1
print("Counter: ", counter)
if (((counter%7) == 0)):
laps = ('Laps: ' + str(math.floor(counter/7)) + " Time: " + str((time.time() - start_time)) + '\n')
file_laps.write(laps)
def Goal_Distances_left(see):
global counter, dist_left, l
dist = 100
for token in see:
if token.dist < dist and -100 < token.rot_y < -80:
if token.info.marker_type == "gold-token":
dist = token.dist
dist_left = ('Dist: ' + str(dist) + " Time: " + str((time.time() - start_time))+ " Lap: " + str(math.floor(counter/7)) + '\n')
l.write(dist_left)
def Goal_Distances_right(see):
global counter, dist_right , r
dist = 100
for token in see:
if token.dist < dist and 80 < token.rot_y < 100:
if token.info.marker_type == "gold-token":
dist = token.dist
dist_right = ('Dist: ' + str(dist) + " Time: " + str((time.time() - start_time)) + " Lap: " + str(math.floor(counter/7)) + '\n')
r.write(dist_right)
def Wrong_Direction(pointed, pre_pointed):
global counter
if(pre_pointed == pointed):
wd = ("Wrong Direction!! " + " Time: " + str((time.time() - start_time)) + " Lap: " + str(math.floor(counter/7)) + '\n')
file_laps.write(wd)