WPILibC++  unspecified
TimedRobot.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 <atomic>
11 #include <memory>
12 
13 #include "IterativeRobotBase.h"
14 #include "Notifier.h"
15 
16 namespace frc {
17 
28  public:
29  static constexpr double kDefaultPeriod = 0.02;
30 
31  void StartCompetition() override;
32 
33  void SetPeriod(double seconds);
34  double GetPeriod() const;
35 
36  protected:
37  TimedRobot();
38  virtual ~TimedRobot();
39 
40  private:
41  std::atomic<double> m_period{kDefaultPeriod};
42 
43  // Prevents loop from starting if user calls SetPeriod() in RobotInit()
44  bool m_startLoop = false;
45 
46  std::unique_ptr<Notifier> m_loop;
47 };
48 
49 } // namespace frc
Definition: RobotController.cpp:14
void StartCompetition() override
Provide an alternate "main loop" via StartCompetition().
Definition: TimedRobot.cpp:19
double GetPeriod() const
Get time period between calls to Periodic() functions.
Definition: TimedRobot.cpp:53
TimedRobot implements the IterativeRobotBase robot program framework.
Definition: TimedRobot.h:27
void SetPeriod(double seconds)
Set time period between calls to Periodic() functions.
Definition: TimedRobot.cpp:42
IterativeRobotBase implements a specific type of robot program framework, extending the RobotBase cla...
Definition: IterativeRobotBase.h:43