WPILibC++  2019.1.1-4-g308bdbe
 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 
45 class IterativeRobotBase : public RobotBase {
46  public:
59  virtual void RobotInit();
60 
68  virtual void DisabledInit();
69 
76  virtual void AutonomousInit();
77 
84  virtual void TeleopInit();
85 
92  virtual void TestInit();
93 
100  virtual void RobotPeriodic();
101 
109  virtual void DisabledPeriodic();
110 
118  virtual void AutonomousPeriodic();
119 
127  virtual void TeleopPeriodic();
128 
136  virtual void TestPeriodic();
137 
138  protected:
144  explicit IterativeRobotBase(double period);
145 
146  virtual ~IterativeRobotBase() = default;
147 
149  IterativeRobotBase& operator=(IterativeRobotBase&&) = default;
150 
151  void LoopFunc();
152 
153  double m_period;
154 
155  private:
156  enum class Mode { kNone, kDisabled, kAutonomous, kTeleop, kTest };
157 
158  Mode m_lastMode = Mode::kNone;
159  Watchdog m_watchdog;
160 
161  void PrintLoopOverrunMessage();
162 };
163 
164 } // 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:30
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:45
virtual void AutonomousInit()
Initialization code for autonomous mode should go here.
virtual void DisabledInit()
Initialization code for disabled mode should go here.