Hi everyone! We are a team from Texas and were beginning Odometery this season. We were looking at Pilons Guide to Odometry and were confused on the third step. What exactly should we update the previous values to?
Here is our code below:
float conversion;
float encoderLeftPrevious;
float encoderRightPrevious;
float encoderBackPrevious;
float encoderLeftChange;
float encoderRightChange;
float encoderBackChange;
void calculateChange()
{
encoderLeftPrevious = encoderLeft.position(rotationUnits::deg);
encoderRightPrevious = encoderRight.position(rotationUnits::deg);
encoderBackPrevious = encoderBack.position(rotationUnits::deg);
while(true)
{
float encoderLeftCurrent = encoderLeft.position(rotationUnits::deg);;
float encoderRightCurrent = encoderRight.position(rotationUnits::deg);
float encoderBackCurrent = encoderBack.position(rotationUnits::deg);
encoderLeftChange = conversion*(encoderLeftCurrent - encoderLeftPrevious);
encoderRightChange = conversion*(encoderRightCurrent - encoderRightPrevious);
encoderBackChange = conversion*(encoderBackCurrent - encoderBackPrevious);
vex::task::sleep(100);
}
//what to set previous values equal to?
}