Quote:
Originally Posted by Zero_Cool
don't forget the switch statement, which can be more useful or better for use in autonomous.
|
Indeed, it's very useful for programmers doing autonomous work to understand the concept of the finite state machine (
http://en.wikipedia.org/wiki/Finite_state_machine), since that is one of the easiest ways to come up with a clearly written and debug-able autonomous routine.
Most of our routines end up looking something like:
Code:
switch (auto_state) {
case INITIALIZE:
Auto_Initialize(); // Set up auto mode
auto_state=FASTASPPROACH
break;
case APPROACH:
// Code that drives towards goals quickly, and at some point
// resets auto_state to SCORE
break;
case SCORE:
// Score many points!
break;
case DONE:
default:
// do nothing!
break;
}