WPILibC++  2020.3.2-60-g3011ebe
TimedRobot.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2017-2020 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 <hal/Types.h>
11 #include <units/units.h>
12 #include <wpi/deprecated.h>
13 
14 #include "frc/ErrorBase.h"
15 #include "frc/IterativeRobotBase.h"
16 
17 namespace frc {
18 
28 class TimedRobot : public IterativeRobotBase, public ErrorBase {
29  public:
30  static constexpr units::second_t kDefaultPeriod = 20_ms;
31 
35  void StartCompetition() override;
36 
40  void EndCompetition() override;
41 
45  units::second_t GetPeriod() const;
46 
55  WPI_DEPRECATED("Use constructor with unit-safety instead.")
56  explicit TimedRobot(double period);
57 
63  explicit TimedRobot(units::second_t period = kDefaultPeriod);
64 
65  ~TimedRobot() override;
66 
67  TimedRobot(TimedRobot&&) = default;
68  TimedRobot& operator=(TimedRobot&&) = default;
69 
70  private:
71  hal::Handle<HAL_NotifierHandle> m_notifier;
72 
73  // The absolute expiration time
74  units::second_t m_expirationTime{0};
75 
79  void UpdateAlarm();
80 };
81 
82 } // namespace frc
frc::TimedRobot::TimedRobot
TimedRobot(double period)
Constructor for TimedRobot.
frc::IterativeRobotBase
IterativeRobotBase implements a specific type of robot program framework, extending the RobotBase cla...
Definition: IterativeRobotBase.h:48
frc::TimedRobot::StartCompetition
void StartCompetition() override
Provide an alternate "main loop" via StartCompetition().
frc::ErrorBase
Base class for most objects.
Definition: ErrorBase.h:104
frc::TimedRobot::EndCompetition
void EndCompetition() override
Ends the main loop in StartCompetition().
frc
A class that enforces constraints on the differential drive kinematics.
Definition: PDPSim.h:16
frc::TimedRobot::GetPeriod
units::second_t GetPeriod() const
Get the time period between calls to Periodic() functions.
frc::TimedRobot
TimedRobot implements the IterativeRobotBase robot program framework.
Definition: TimedRobot.h:28