-
Notifications
You must be signed in to change notification settings - Fork 0
/
arduinoCommands.py
107 lines (105 loc) · 5.56 KB
/
arduinoCommands.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
from directions import *
class Commands:
def __init__(self,path):
directions = Directions(path).cardinalList
self.commands = ''
directions_dict = {'forward':'a','left':'b','stop':'c','right':'d','leftDiagonal':'e','rightDiagonal':'f'}
auxDirection = 0
for direction in directions:
if (auxDirection == 0):
self.commands += directions_dict['forward']
auxDirection = direction
else:
if (auxDirection == 'N'):
if (direction == 'O'):
self.commands += directions_dict['left']
elif (direction == 'NO'):
self.commands += directions_dict['leftDiagonal']
elif (direction == 'N'):
self.commands += directions_dict['forward']
elif (direction == 'NE'):
self.commands += directions_dict['rightDiagonal']
elif (direction == 'E'):
self.commands += directions_dict['right']
elif (auxDirection == 'NE'):
if (direction == 'NO'):
self.commands += directions_dict['left']
elif (direction == 'N'):
self.commands += directions_dict['leftDiagonal']
elif (direction == 'NE'):
self.commands += directions_dict['forward']
elif (direction == 'E'):
self.commands += directions_dict['rightDiagonal']
elif (direction == 'SE'):
self.commands += directions_dict['right']
elif (auxDirection == 'E'):
if (direction == 'N'):
self.commands += directions_dict['left']
elif (direction == 'NE'):
self.commands += directions_dict['leftDiagonal']
elif (direction == 'E'):
self.commands += directions_dict['forward']
elif (direction == 'SE'):
self.commands += directions_dict['rightDiagonal']
elif (direction == 'S'):
self.commands += directions_dict['right']
elif (auxDirection == 'SE'):
if (direction == 'NE'):
self.commands += directions_dict['left']
elif (direction == 'E'):
self.commands += directions_dict['leftDiagonal']
elif (direction == 'SE'):
self.commands += directions_dict['forward']
elif (direction == 'S'):
self.commands += directions_dict['rightDiagonal']
elif (direction == 'SO'):
self.commands += directions_dict['right']
elif (auxDirection == 'S'):
if (direction == 'E'):
self.commands += directions_dict['left']
elif (direction == 'SE'):
self.commands += directions_dict['leftDiagonal']
elif (direction == 'S'):
self.commands += directions_dict['forward']
elif (direction == 'SO'):
self.commands += directions_dict['rightDiagonal']
elif (direction == 'O'):
self.commands += directions_dict['right']
elif (auxDirection == 'SO'):
if (direction == 'SE'):
self.commands += directions_dict['left']
elif (direction == 'S'):
self.commands += directions_dict['leftDiagonal']
elif (direction == 'SO'):
self.commands += directions_dict['forward']
elif (direction == 'O'):
self.commands += directions_dict['rightDiagonal']
elif (direction == 'NO'):
self.commands += directions_dict['right']
elif (auxDirection == 'O'):
if (direction == 'S'):
self.commands += directions_dict['left']
elif (direction == 'SO'):
self.commands += directions_dict['leftDiagonal']
elif (direction == 'O'):
self.commands += directions_dict['forward']
elif (direction == 'NO'):
self.commands += directions_dict['rightDiagonal']
elif (direction == 'N'):
self.commands += directions_dict['right']
elif (auxDirection == 'NO'):
if (direction == 'SO'):
self.commands += directions_dict['left']
elif (direction == 'O'):
self.commands += directions_dict['leftDiagonal']
elif (direction == 'NO'):
self.commands += directions_dict['forward']
elif (direction == 'N'):
self.commands += directions_dict['rightDiagonal']
elif (direction == 'NE'):
self.commands += directions_dict['right']
auxDirection = direction
self.commands += directions_dict['stop']
print(self.commands)
# commands = Commands([[0, 0], [0, 1], [1, 2], [2, 3], [3, 3], [4, 2], [5, 1], [5, 0], [4, 0]]).commands
# print(commands)