This issue has been mentioned before in this thread but I wanted to bring it up again. In that thread, the context was a controller disconnect, but a similar thing happens with a momentary motor disconnection (e,g., a flaky cable). When it reconnects, repeated identical motor commands are ignored. A programmer might monitor for disconnects, but Motor.installed() will only return false if the disconnect is long enough.
For example:
while(true) {
Motor1.spin(forward, 20, rpm);
if (!Motor1.installed()) {
while(!Motor1.installed()) {
wait(20, msec);
}
wait(100, msec); // calling the spin function too soon after reconnect doesn’t work
Motor1.spin(forward, 0, rpm);
}
wait(20, msec);
}
If the motor disconnects for a split second, no “Disconnected” notice is printed to the console, but the motor does not reliably restart (sometimes it does — I’m not sure why.)
This isn’t a problem for something like a drivetrain where moving the joystick will send a new instruction to the motor. But it could shut down a flywheel for a whole autonomous skills run. (I think this happened twice to one of my teams last weekend, although I can’t be sure.) Or anything on a bang-bang controller, or even a PID controller far enough from the set point to demand maximum motor voltage. I wonder how many cases of “my flywheel/intake/whatever didn’t run and I have no idea why” this has caused.