Fixed some bugs when recentering the camera.

This commit is contained in:
2014-04-04 10:32:29 -04:30
parent 1481ebe349
commit 50278109eb
2 changed files with 9 additions and 8 deletions

View File

@@ -122,8 +122,9 @@ public class NxtAR_bot{
* Force quit. * Force quit.
*/ */
@Override @Override
public void buttonPressed(Button b) { public void buttonPressed(Button b){
quit(); System.exit(0);
//quit();
} }
/** /**

View File

@@ -79,7 +79,7 @@ public class MotorControlThread extends Thread{
message[1] = inputStream.readByte(); message[1] = inputStream.readByte();
// Decode the instruction parameters. // Decode the instruction parameters.
recenterMotorB = (message[0] & MotorMasks.RECENTER) > 0 ? true : false; recenterMotorB = (message[0] & MotorMasks.RECENTER) > 0 ? true : false;
motorA = (message[0] & MotorMasks.MOTOR_A) > 0 ? true : false; motorA = (message[0] & MotorMasks.MOTOR_A) > 0 ? true : false;
motorB = (message[0] & MotorMasks.MOTOR_B) > 0 ? true : false; motorB = (message[0] & MotorMasks.MOTOR_B) > 0 ? true : false;
motorC = (message[0] & MotorMasks.MOTOR_C) > 0 ? true : false; motorC = (message[0] & MotorMasks.MOTOR_C) > 0 ? true : false;
@@ -113,12 +113,12 @@ public class MotorControlThread extends Thread{
} }
if(recenterMotorB){ if(recenterMotorB){
// Return motor B to it's origin. Rotate in the direction System.out.println("RECENTER");
// that implies less movement. // Return motor B to it's origin.
Motor.B.setSpeed(50 * Battery.getVoltage());
tacho = Motor.B.getTachoCount() % 360; tacho = Motor.B.getTachoCount() % 360;
rotation = tacho > 180 ? 360 - tacho : -(tacho); rotation = -(tacho);
Motor.B.rotate(rotation); Motor.B.rotate(rotation, false);
Motor.B.resetTachoCount();
} }
}catch(IOException io){ }catch(IOException io){