Makes IterativeRobot not double check for new control data (#253)

Previously could cause a race condition. Also moves wait to the top of
the loop in order to avoid having an initial loop be ran before data can
be check.

Sim is handled in #232, except that needs to be updated as well to move
the wait to the top of the loop.
This commit is contained in:
Thad House
2016-10-02 09:05:32 -07:00
committed by Peter Johnson
parent fd52912d74
commit e65f9908d7
2 changed files with 12 additions and 27 deletions

View File

@@ -39,6 +39,8 @@ void IterativeRobot::StartCompetition() {
// loop forever, calling the appropriate mode-dependent function
lw->SetEnabled(false);
while (true) {
// wait for driver station data so the loop doesn't hog the CPU
m_ds.WaitForData();
// Call the appropriate function depending upon the current robot mode
if (IsDisabled()) {
// call DisabledInit() if we are now just entering disabled mode from
@@ -99,8 +101,6 @@ void IterativeRobot::StartCompetition() {
TeleopPeriodic();
}
RobotPeriodic();
// wait for driver station data so the loop doesn't hog the CPU
m_ds.WaitForData();
}
}