Revision d607fcef devices/DiWheelDrive/userthread.cpp
devices/DiWheelDrive/userthread.cpp | ||
---|---|---|
15 | 15 |
CHARGING |
16 | 16 |
}; |
17 | 17 |
|
18 |
enum msg_content{ |
|
19 |
STOP, |
|
20 |
START, |
|
21 |
EDGE_LEFT, |
|
22 |
EDGE_RIGHT, |
|
23 |
FUZZY, |
|
24 |
DOCKING |
|
25 |
}; |
|
26 |
|
|
18 | 27 |
// User thread state: |
19 | 28 |
states utState = states::FOLLOW_LINE; |
20 | 29 |
|
... | ... | |
147 | 156 |
int rpmSpeed[2] = {0}; |
148 | 157 |
int stop[2] = {0}; |
149 | 158 |
int proxyWheelThresh = 18000; |
159 |
LineFollowStrategy lStrategy; |
|
150 | 160 |
for (uint8_t led = 0; led < 8; ++led) { |
151 | 161 |
global.robot.setLightColor(led, Color(Color::BLACK)); |
152 | 162 |
} |
... | ... | |
184 | 194 |
this->sleep(1000); |
185 | 195 |
lightAllLeds(Color::BLACK); |
186 | 196 |
running = !running; |
197 |
// If message was received handle it here: |
|
198 |
} else if(global.msgReceived){ |
|
199 |
|
|
200 |
global.msgReceived = false; |
|
201 |
running = true; |
|
202 |
switch(global.lfStrategy){ |
|
203 |
case msg_content::START: |
|
204 |
break; |
|
205 |
case msg_content::STOP: |
|
206 |
running = false; |
|
207 |
break; |
|
208 |
case msg_content::EDGE_RIGHT: |
|
209 |
lStrategy = LineFollowStrategy::EDGE_RIGHT; |
|
210 |
break; |
|
211 |
case msg_content::EDGE_LEFT: |
|
212 |
lStrategy = LineFollowStrategy::EDGE_LEFT; |
|
213 |
break; |
|
214 |
case msg_content::FUZZY: |
|
215 |
lStrategy = LineFollowStrategy::FUZZY; |
|
216 |
break; |
|
217 |
case msg_content::DOCKING: |
|
218 |
utState = states::OCCUPY; |
|
219 |
lStrategy = LineFollowStrategy::EDGE_RIGHT; |
|
220 |
break; |
|
221 |
default: |
|
222 |
break; |
|
223 |
} |
|
224 |
|
|
187 | 225 |
} |
226 |
|
|
188 | 227 |
if(running){ |
189 | 228 |
switch(utState){ |
190 | 229 |
case states::FOLLOW_LINE:{ |
191 |
LineFollowStrategy lStrategy = determineStrategy(); |
|
230 |
// LineFollowStrategy lStrategy = determineStrategy();
|
|
192 | 231 |
if(lStrategy == LineFollowStrategy::DOCKING){ |
193 | 232 |
utState = states::OCCUPY; |
194 | 233 |
break; |
... | ... | |
230 | 269 |
} |
231 | 270 |
|
232 | 271 |
// Set correct following |
233 |
lf.setStrategy(LineFollowStrategy::EDGE_RIGHT); |
|
272 |
// lf.setStrategy(LineFollowStrategy::EDGE_RIGHT);
|
|
234 | 273 |
lf.followLine(rpmSpeed); |
235 | 274 |
setRpmSpeed(rpmSpeed); |
236 | 275 |
|
... | ... | |
240 | 279 |
break; |
241 | 280 |
} |
242 | 281 |
case states::CHARGING:{ |
282 |
setRpmSpeed(stop); |
|
243 | 283 |
break; |
244 | 284 |
} |
245 | 285 |
default:{ |
Also available in: Unified diff