Description
For safety reasons, if an OpMode refuses to begin to stop after a few seconds of the "stop" button being pressed, fails to initialize in a timely manner, or fails to stop in a timely manner, the OpModeManagerImpl.OpModeStuckCodeMonitor.Runner.run() method sends a kill request that shuts down the RC app, which is restarted a few seconds later.
However, the watching class fails to force the REV hub to stop powering motors. In fact, since the active OpMode is shutdown by the app crash, motors are stuck in their last state until the app relaunches. This uncontrolled period can result in damage to the robot, people/items/other robots surrounding it, the field, etc., and is itself a safety issue.
Ensuring that all hardware is powered off is something that is taken care of in other places in the OpModeManagerImpl class. Specifically, this code seems to shut down all powered motors:
Iterator var1 = this.hardwareMap.getAll(DcMotorSimple.class).iterator();
while(var1.hasNext()) {
DcMotorSimple motor = (DcMotorSimple)var1.next();
if (motor.getPower() != 0.0D) {
motor.setPower(0.0D);
}
}
The fact that the RC app restarts itself successfully after one of these shutdowns is proof that the OpModeManagerImpl.OpModeStuckCodeMonitor.Runner.run() method is run. The app killing is part of this method. However, in the same way that the code gives a message on the phones to notify the user as to what is happening, it would seem that shutting down hardware prior to the app's shutdown is plausible and would greatly improve the safety of the SDK.