Add loop timing to IterativeRobot and TimedRobot (#781)

This commit is contained in:
Tyler Veness
2018-06-24 02:29:21 -05:00
committed by Peter Johnson
parent 50b13d2f36
commit a818c7fd47
11 changed files with 409 additions and 63 deletions

View File

@@ -33,36 +33,27 @@ class TimedRobot : public IterativeRobotBase, public ErrorBase {
void StartCompetition() override;
/**
* Set time period between calls to Periodic() functions.
*
* A timer event is queued for periodic event notification. Each time the
* interrupt occurs, the event will be immediately requeued for the same time
* interval.
*
* @param period Period in seconds.
*/
void SetPeriod(double seconds);
/**
* Get time period between calls to Periodic() functions.
* Get the time period between calls to Periodic() functions.
*/
double GetPeriod() const;
protected:
TimedRobot();
/**
* Constructor for TimedRobot.
*
* @param period Period in seconds.
*/
explicit TimedRobot(double period = kDefaultPeriod);
~TimedRobot() override;
private:
// Prevents loop from starting if user calls SetPeriod() in RobotInit()
bool m_startLoop = false;
HAL_NotifierHandle m_notifier{0};
// The absolute expiration time
double m_expirationTime = 0;
// The relative time
double m_period = kDefaultPeriod;
double m_period;
/**
* Update the HAL alarm time.