WPILib  2014.0
WPIRoboticsLibraryforFRC
 All Classes Functions Variables Pages
IterativeRobot.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
5 /*----------------------------------------------------------------------------*/
6 
7 #ifndef ROBOT_ITERATIVE_H_
8 #define ROBOT_ITERATIVE_H_
9 
10 #include "Timer.h"
11 #include "RobotBase.h"
12 
41 class IterativeRobot : public RobotBase {
42 public:
43  /*
44  * The default period for the periodic function calls (seconds)
45  * Setting the period to 0.0 will cause the periodic functions to follow
46  * the Driver Station packet rate of about 50Hz.
47  */
48  static constexpr double kDefaultPeriod = 0.0;
49 
50  virtual void StartCompetition();
51 
52  virtual void RobotInit();
53  virtual void DisabledInit();
54  virtual void AutonomousInit();
55  virtual void TeleopInit();
56  virtual void TestInit();
57 
58  virtual void DisabledPeriodic();
59  virtual void AutonomousPeriodic();
60  virtual void TeleopPeriodic();
61  virtual void TestPeriodic();
62 
63  void SetPeriod(double period);
64  double GetPeriod();
65  double GetLoopsPerSec();
66 
67 protected:
68  virtual ~IterativeRobot();
70 
71 private:
72  bool NextPeriodReady();
73 
74  bool m_disabledInitialized;
75  bool m_autonomousInitialized;
76  bool m_teleopInitialized;
77  bool m_testInitialized;
78  double m_period;
79  Timer m_mainLoopTimer;
80 };
81 
82 #endif
83 
virtual void RobotInit()
Definition: IterativeRobot.cpp:222
Definition: IterativeRobot.h:41
virtual void DisabledInit()
Definition: IterativeRobot.cpp:233
void SetPeriod(double period)
Definition: IterativeRobot.cpp:46
virtual void TeleopPeriodic()
Definition: IterativeRobot.cpp:311
virtual void TestInit()
Definition: IterativeRobot.cpp:266
virtual void StartCompetition()
Definition: IterativeRobot.cpp:93
double GetPeriod()
Definition: IterativeRobot.cpp:67
virtual void TeleopInit()
Definition: IterativeRobot.cpp:255
Definition: RobotBase.h:37
virtual void AutonomousInit()
Definition: IterativeRobot.cpp:244
virtual void AutonomousPeriodic()
Definition: IterativeRobot.cpp:294
IterativeRobot()
Definition: IterativeRobot.cpp:24
virtual void DisabledPeriodic()
Definition: IterativeRobot.cpp:277
double GetLoopsPerSec()
Definition: IterativeRobot.cpp:76
Definition: Timer.h:27
virtual ~IterativeRobot()
Definition: IterativeRobot.cpp:37
virtual void TestPeriodic()
Definition: IterativeRobot.cpp:328