Check out
http://users.wpi.edu/~bamiller/WPIRo...ive_robot.html
Quote:
Init() functions -- each of the following functions is called once when the appropriate mode is entered:
DisabledInit() -- called only when first disabled
AutonomousInit() -- called each and every time autonomous is entered from another mode
TeleopInit() -- called each and every time teleop is entered from another mode
Periodic() functions -- each of these functions is called iteratively at the appropriate periodic rate (aka the "slow loop"). The default period of the iterative robot is 10,000 microseconds, giving a periodic frequency of 100Hz (100 times per second).
DisabledPeriodic()
AutonomousPeriodic()
TeleopPeriodic()
Continuous() functions -- each of these functions is called repeatedly as fast as possible:
DisabledContinuous()
AutonomousContinuous()
TeleopContinuous()
|
The basic idea is you have the ability to initialize something (call it once) when starting each mode. Then you have the ability to do stuff in a repeated fashion, without putting in your own loops - using while or for loops in this type of robot structure is something best to be avoided!
They provide two different types of loops. The basic idea here being that there's stuff that you need to update periodically, like the values you send to your drive motors, but that doesn't have to be done as quickly as possible (waiting 1/100 of a second is OK). But there are other things that you need to do as frequently as possible, like try to detect state changes on a limit switch. You can rely on these functions being called for you repeatedly for as long as the robot is in that state (teleop, auto, disabled).