-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlgo.py
82 lines (53 loc) · 1.94 KB
/
Algo.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
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import import_ipynb
import configure as cfg
# In[2]:
class Algo:
def __init__(self):
self.dir = cfg.Forward
self.speed=cfg.DSpeed
self.curr_speed = cfg.OSpeed
def run(self, x):
if any(self.curr_speed):
self.speed = self.curr_speed
if x==cfg.InputType.START:
self.dir = cfg.Forward
self.speed = cfg.OSpeed
elif x==cfg.InputType.FORWARD:
self.dir = cfg.Forward
elif x==cfg.InputType.BACKWARD:
self.dir = cfg.Backward
elif x==cfg.InputType.LOWSPEED:
self.speed = cfg.LSpeed
self.curr_speed = self.speed
elif x==cfg.InputType.MEDIUMSPEED:
self.speed = cfg.MSpeed
self.curr_speed = self.speed
elif x==cfg.InputType.HIGHSPEED:
self.speed = cfg.HSpeed
self.curr_speed = self.speed
elif x==cfg.InputType.STOP:
self.dir = cfg.Stop
elif x==cfg.InputType.RIGHT:
self.curr_speed = self.speed
self.speed = [0, self.curr_speed[1]]
elif x==cfg.InputType.LEFT:
self.curr_speed = self.speed
self.speed = [self.curr_speed[0],0]
elif x==cfg.InputType.PAUSE:
self.speed = cfg.DSpeed
elif x==cfg.InputType.EXIT:
self.dir=None
self.speed=None
else:
print("<<< wrong data >>>")
print("please enter the defined data to continue.....")
def get_dir(self):
print(self.dir)
return self.dir
def get_speed(self):
print(self.speed)
return self.speed
# In[ ]: