blob: 0f3add326d3eb1b566d014d8c9d008802fcbe1b2 [file] [log] [blame]
Brian Silverman41cdd3e2019-01-19 19:48:58 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) 2008-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#include "frc/IterativeRobot.h"
9
10#include <hal/HAL.h>
11
12#include "frc/DriverStation.h"
13
14using namespace frc;
15
16static constexpr double kPacketPeriod = 0.02;
17
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}