WPILibC++  2019.1.1-beta-2-2-gf54c0f7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
IterativeRobotBase.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2017-2018 FIRST. 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 the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include "frc/RobotBase.h"
11 #include "frc/Watchdog.h"
12 
13 namespace frc {
14 
44 class IterativeRobotBase : public RobotBase {
45  public:
58  virtual void RobotInit();
59 
67  virtual void DisabledInit();
68 
75  virtual void AutonomousInit();
76 
83  virtual void TeleopInit();
84 
91  virtual void TestInit();
92 
99  virtual void RobotPeriodic();
100 
108  virtual void DisabledPeriodic();
109 
117  virtual void AutonomousPeriodic();
118 
126  virtual void TeleopPeriodic();
127 
135  virtual void TestPeriodic();
136 
137  protected:
143  explicit IterativeRobotBase(double period);
144 
145  virtual ~IterativeRobotBase() = default;
146 
148  IterativeRobotBase& operator=(IterativeRobotBase&&) = default;
149 
150  void LoopFunc();
151 
152  double m_period;
153 
154  private:
155  enum class Mode { kNone, kDisabled, kAutonomous, kTeleop, kTest };
156 
157  Mode m_lastMode = Mode::kNone;
158  Watchdog m_watchdog;
159 
160  void PrintLoopOverrunMessage();
161 };
162 
163 } // namespace frc
virtual void AutonomousPeriodic()
Periodic code for autonomous mode should go here.
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
IterativeRobotBase(double period)
Constructor for IterativeRobotBase.
virtual void TeleopInit()
Initialization code for teleop mode should go here.
virtual void DisabledPeriodic()
Periodic code for disabled mode should go here.
virtual void RobotPeriodic()
Periodic code for all modes should go here.
virtual void TeleopPeriodic()
Periodic code for teleop mode should go here.
virtual void RobotInit()
Robot-wide initialization code should go here.
Implement a Robot Program framework.
Definition: RobotBase.h:51
A class that's a wrapper around a watchdog timer.
Definition: Watchdog.h:28
virtual void TestInit()
Initialization code for test mode should go here.
virtual void TestPeriodic()
Periodic code for test mode should go here.
IterativeRobotBase implements a specific type of robot program framework, extending the RobotBase cla...
Definition: IterativeRobotBase.h:44
virtual void AutonomousInit()
Initialization code for autonomous mode should go here.
virtual void DisabledInit()
Initialization code for disabled mode should go here.