Description
Currently, to reset the motor encoder's count, you would set its run mode to STOP_AND_RESET_ENCODER. This then requires you to set the motor's mode back to whatever it was previously, which isn't particularly difficult, just annoying and unintuitive.
Because resetting the encoder is an entirely different Lynx command from setting the run mode, I believe it would be easier to have a method in DcMotor (and DcMotorController) that would essentially be this (in LynxDcMotorController):
public void stopAndResetEncoder() {
internalSetMotorPower(motor, 0);
LynxCommand command = new LynxResetMotorEncoderCommand(this.getModule(), motor);
try {
if (DEBUG) RobotLog.vv(TAG, "setMotorChannelMode: mod=%d motor=%d mode=%s power=%f zero=%s",
getModuleAddress(), motor, mode.toString(), prevPower, zeroPowerBehavior.toString());
command.send();
}
catch (InterruptedException|RuntimeException|LynxNackException e)
{
handleException(e);
}
}
STOP_AND_RESET_ENCODER should then be removed from the RunMode choices. Also, in this implementation stopAndResetEncoder()
would actually stop the motor (as in set its power to 0 and do not set its power back to whatever it was before at the end), because that is more intuitive based on the name.