-
Notifications
You must be signed in to change notification settings - Fork 0
/
remoted_car.py
39 lines (38 loc) · 1.02 KB
/
remoted_car.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
class remoted_car:
def __init__(self):
"""
do some inintialization
"""
self.__command_left = 1
self.__command_right = 2
self.__command_head = 3
self.__command_stop = 4
self.__command=4
return
def get_c(self, dist):
if dist<0.5 and dist>0.2:
self.__command= self.__command_left
elif dist>=0.5:
self.__command= self.__command_head
else:
self.__command = self.__command_stop
def turn_left(self):
print("turn left")
return
def turn_right(self):
print("turn right")
return
def head(self):
print("head")
return
def stop(self):
print("stop")
return
def move(self):
if self.__command==self.__command_head:
self.head()
elif self.__command==self.__command_stop:
self.stop()
elif self.__command==self.__command_left:
self.turn_left()
return