FIRST-Tech-Challenge / FIRST-Tech-Challenge/FtcRobotController

Have a method for resetting motor encoders instead of treating it as a run mode

Open
#1,489 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.3k
Forks
9.9k
Avg merge
18m
Merged PRs (30d)
1

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.