Skip to content

Instantly share code, notes, and snippets.

@jimmyli97
Forked from TheAlchenmist/EncoderCheck.c
Last active August 29, 2015 14:15
Show Gist options
  • Save jimmyli97/2bb7732b35176445aaad to your computer and use it in GitHub Desktop.
Save jimmyli97/2bb7732b35176445aaad to your computer and use it in GitHub Desktop.
#define ENC_ERROR_THRESHOLD 3000
int checkEnc = nMotorEncoder[curMotor];
int knownGoodEnc = motorStates[curMotor].lastRealEncoderPos;
int curEnc;
if (abs(checkEnc - knownGoodEnc) > ENC_ERROR_THRESHOLD) {
//do nothing because enc val is bad
} else {
curEnc = checkEnc; //enc val is good
motorStates[curMotor].lastRealEncoderPos = curEnc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment