mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpilib] LinearOpMode: wait for mode change to return from OpModeRun (#8477)
We need to wait, or otherwise OpModeRobot will immediately reinstantiate and re-run the opmode, which is generally undesirable (e.g. for autonomous). Fixes #8475.
This commit is contained in:
@@ -67,6 +67,12 @@ public abstract class LinearOpMode implements OpMode {
|
||||
|
||||
try (DriverStationModeThread bgThread = new DriverStationModeThread(word)) {
|
||||
run();
|
||||
|
||||
// Wait for opmode to be stopped or disabled, otherwise OpModeRobot will recreate and re-run
|
||||
// the opmode immediately.
|
||||
while (isRunning() && DriverStation.isEnabled() && DriverStation.getOpModeId() == opModeId) {
|
||||
Thread.sleep(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user