This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define LIFT_UP_POW -100 | |
#define ENC_SIGN sgn(LIFT_UP_POW) | |
#define LIFT_MAX ENC_SIGN * 9800 //high goal | |
#define NINETY_GOAL ENC_SIGN * 7400 | |
#define SIXTY_GOAL ENC_SIGN * 4600 | |
#define THIRTY_GOAL ENC_SIGN * 2000 | |
#define LIFT_MIN 0 | |
void joyLift(DesiredMotorVals *desiredMotorVals, DesiredEncVals *desiredEncVals, TJoystick *joyState){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Struct definition for holding states of motors | |
typedef struct MotorState { | |
long encoder; | |
long lastRealEncoderPos; | |
} MotorState; | |
//Array for storing MotorState for each motor | |
static MotorState motorStates[MAX_NUM_MOTORS]; | |
//Called once per main loop to update MotorState |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define MAX_HARVESTMOVE_TIME_POS 800 | |
typedef struct MotorState { | |
... //encoder data | |
long timePosMs; //stores position in "time" (50 means net movement forward for 50 ms) | |
long lastUpdateTimeMs; //last time this motorstate as updated | |
} MotorState; | |
void motorUpdateState() { | |
for (int i=0; i<NUM_MOTORS; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<mws:expr url="math.3.0"> | |
<math xmlns="http://www.w3.org/1998/Math/MathML" id="p1.1.m1" class="ltx_Math" alttext="{\displaystyle a}" display="inline" xml:id="p1.1.m1.1" xref="p1.1.m1.1.cmml"> | |
<semantics xml:id="p1.1.m1.1a" xref="p1.1.m1.1.cmml"> | |
<mi xml:id="p1.1.m1.1.1" xref="p1.1.m1.1.1.cmml">a</mi> | |
<annotation-xml encoding="MathML-Content" xml:id="p1.1.m1.1.cmml" xref="p1.1.m1.1"> | |
<ci xml:id="p1.1.m1.1.1.cmml" xref="p1.1.m1.1.1">a</ci> | |
</annotation-xml> | |
<annotation encoding="application/x-tex" xml:id="p1.1.m1.1b" xref="p1.1.m1.1.cmml">{\displaystyle a}</annotation> | |
</semantics> | |
</math> |
OlderNewer