Closed JohnMMcD closed 4 years ago
Have you tested this to verify there is a problem.?
while (!(isStarted() || isStopRequested())) { ... }; should have the same functionality as waitForStart().
The code in question replaces wairForStart() with a while loop that displays the light level while it waits for the user to press Start.
isStarted() and isStopRequested() will both return false until either start or stop are pressed. So the while will loop.
Phil.
Phil, I confess that I have not experimentally verified this. I was going by the behavior reported by the forum poster and a code comparison between PushbotAutoDriveToLine_Linear.java and PushbotAutoDriveByTime_Linear.java , and specifically by the fact that both include a comment "Wait for the game to start (driver presses PLAY)", while one includes the waitForStart and the other doesn't. I think my logic was faulty, though, because there is more than one way to make the wait happen. I'm going to close this until I have more evidence. Sorry for the trouble.
The example op mode starts prematurely (during init) because of a missing waitForStart() command. This problem was noted in this forum posting.
The waitForStart() command should be added after line 92.
92 // Wait for the game to start (driver presses PLAY) 93 waitForStart();
In diff-speak, this can be resolved by: