forked from jwarshaw/RaspberryDrive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpseudocode.py
113 lines (95 loc) · 2.49 KB
/
pseudocode.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
108
109
110
111
112
113
def driveforward(time):
FOR each second in time
goforward(1)
IF isblocked?()
return false
END
return true
def drivebackward(time):
FOR each second in time
gobackward(1)
IF isblocked?()
return false
END
return true
def isblocked?():
IF checkcamera() && checkproximity()
return true
ELSE
return false
END
def goforward(time):
FOR the length of time
sendgoforwardsignaltocar()
updatestraightcoordinates(time,"forward")
return ;
def gobackward(time):
FOR the length of time
sendgobackwardsignaltocar()
updatestraightcoordinates(time,"backward")
return
def goforwardright(time):
FOR the length of time
sendgobackwardsignaltocar()
sendgorightsignaltocar()
return
def goforwardleft(time):
FOR the length of time
sendgobackwardsignaltocar()
sendgorightsignaltocar()
return
def maneuverright(backuptime,rightime):
gobackward(backuptime)
goright(righttime)
return
def checkcamera():
image = getimage()
parseimage(image)
return
def checkproximity():
proximity = getproximitysignal()
parseproximitysignal(image)
return
def initialize(target_x, target_y):
# carspeed = TBD
# createcoordinates(0,0,90)
# settargets(target_x,target_y)
# return;
# def createcoordinates(initial_x,initial_y,initial_heading):
# x = initial_x
# y = initial_y
# heading = initial_heading
# return;
# def settargets(target_x,target_y):
# final_x = target_x
# final_y = target_y
# return;
# def directiontotarget():
# return math.degrees(math.atan((final_y - y)/(final_x - x)))
# def go():
# orientdirection()
# drivetotarget
# return ;
# def orientdirection
# if
# def updatestraightcoordinates(time,direction):
# sphericalheading = heading * math.pi / 180
# IF direction == "forward"
# x = x + time * carspeed * math.cos(sphericalheading)
# y = y + time * carspeed * math.sin(sphericalheading)
# ELSE
# x = x - time * carspeed * math.cos(sphericalheading)
# y = y - time * carspeed * math.sin(sphericalheading)
# END
# return
# def updateturncoordinates(time,turningdirection):
# sphericalheading = math.radians(heading)
# FOR each 10th of a second in time
# IF turningdirection == "right"
# sphericalheading = sphericalheading - directionchangepertime
# ELSE
# sphericalheading = sphericalheading + directionchangepertime
# END
# x = x + time * carspeed * math.cos(sphericalheading)
# y = y + time * carspeed * math.sin(sphericalheading)
# return