mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
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:
committed by
Peter Johnson
parent
fd52912d74
commit
e65f9908d7
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user