-
Notifications
You must be signed in to change notification settings - Fork 1
/
fireFighter.bas
122 lines (86 loc) · 2.73 KB
/
fireFighter.bas
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
114
115
116
117
118
119
120
121
122
'Main Program for v2 of the FireFighter Bot
'written by Patrick Leiser, John Schneider, Kendrick Moore[insert your name here], ...
'and the rest of the firebot team in Sierra College Robotics Club [Team]
goto start
#include "include/40X2Symbols.bas"
#include "include/sensorRoutines.bas"
#include "include/motorRoutines.bas"
'''To consider: worth making a setup.bas include file? or keep in main file?
start:
timer = 10
gosub verifychip
hi2csetup i2cmaster, slaveaddr, i2cfast, i2cbyte
pushram
gosub setupmotors
popram
high fanpin 'starts with the fan off
toggle green
do while gobutton = 0
gosub mgetpulses
gosub getAlignmentR
gosub getAlignmentF
sertxd("waiting for start button")
high red
toggle white, green
loop
argb1=50 'was 10 changed to 50
gosub setspeed 'set speed to 10 (5%)
'if timer = 0 then ''should be unnecessary. delete?
'settimer t1s_8
'endif
gosub goforward
pause 3000
'do while timer < 3
' gosub goforward
'loop
low red, white, green
main:
gosub flamereact
; data collection for wall alignment and distance
gosub mgetpulses
gosub getAlignmentR
'sertxd("RightDir: ",#rightDir, cr,lf, "RightAngle: ",#RightAngle, cr,lf, "RightDistance", #rightDistance,cr,lf,cr,lf)
'sertxd("FrontDir: ",#frontDir, cr,lf, "FrontAngle: ",#frontAngle, cr,lf, "FrontDistance", #frontDistance,cr,lf,cr,lf)
'sertxd("RightDir: ", #rightDir, cr, lf, "RightAngle: ", #rightAngle, cr, lf, "RightDistance: ", #rightDistance, cr, lf, cr, lf)
hi2cin slaveerrorstatusflags_ptr, (slaveerrorstatusflags)
hi2cin slavetimestamp_ptr, (slavetimestamp)
'Simple testing
'sertxd("error status flags: ",#slaveerrorstatusflags,cr,lf)
'sertxd("timestamp: ",#slavetimestamp,cr,lf)
argb1=15
'gosub rightwalldistance
gosub resetSuggestion
gosub rightwallsuggest
gosub frontwallsuggest
gosub resetSuggestion
'if firesense=1 then
gosub flamecheck
'endif
argb4 = 15
gosub rightwalldistancesuggestV
'gosub emergencystop
'gosub rightwalldistancesuggest
'gosub frontwallalignsuggest
'gosub rightwallsuggest
gosub frontwallsuggest
'gosub hardmovecheck
sertxd("Behavior ",#SuggestedBehavior, cr,lf, "priority: ",#SuggestionPriority, cr,lf, "intensity:", #SuggestionIntensity,cr,lf,cr,lf)
'gosub debugled
on SuggestedBehavior gosub idlestop, goforward, proportionalSteerRight, proportionalSteerLeft, fixedturnright, fixedturnleft, powerstop
goto main
ultratest:
gosub mgetpulses
sertxd("Acting on sensor values ",#usrf1, " and ",#usrf2, cr,lf)
if usrf2 < 8 then
if usrf1 <8 then
gosub gobackward
else
gosub idlestop
endif
elseif usrf1 < 8 then
gosub idlestop
else
gosub goforward
endif
sertxd("usrf data: ",#returnb1,cr,lf)
return