blob: 950b239e045268f4139270c8e0b6371941ce4084 [file] [log] [blame]
Brian Silverman41cdd3e2019-01-19 19:48:58 -08001/*----------------------------------------------------------------------------*/
James Kuszmaul4f3ad3c2019-12-01 16:35:21 -08002/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
Brian Silverman41cdd3e2019-01-19 19:48:58 -08003/* 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#include "frc/IterativeRobot.h"
9
10#include <hal/HAL.h>
11
12#include "frc/DriverStation.h"
13
14using namespace frc;
15
James Kuszmaul4f3ad3c2019-12-01 16:35:21 -080016static constexpr auto kPacketPeriod = 0.02_s;
Brian Silverman41cdd3e2019-01-19 19:48:58 -080017
18IterativeRobot::IterativeRobot() : IterativeRobotBase(kPacketPeriod) {
19 HAL_Report(HALUsageReporting::kResourceType_Framework,
20 HALUsageReporting::kFramework_Iterative);
21}
22
23void IterativeRobot::StartCompetition() {
24 RobotInit();
25
26 // Tell the DS that the robot is ready to be enabled
27 HAL_ObserveUserProgramStarting();
28
29 // Loop forever, calling the appropriate mode-dependent function
30 while (true) {
31 // Wait for driver station data so the loop doesn't hog the CPU
32 DriverStation::GetInstance().WaitForData();
33
34 LoopFunc();
35 }
36}