View Single Post
  #3   Spotlight this post!  
Unread 01-07-2013, 15:18
Jon Stratis's Avatar
Jon Stratis Jon Stratis is offline
Electrical/Programming Mentor
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,738
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
Re: Switching to Iterative

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).
__________________
2007 - Present: Mentor, 2177 The Robettes
LRI: North Star 2012-2016; Lake Superior 2013-2014; MN State Tournament 2013-2014, 2016; Galileo 2016; Iowa 2017
2015: North Star Regional Volunteer of the Year
2016: Lake Superior WFFA
Reply With Quote