Fixed some bugs when recentering the camera.
This commit is contained in:
@@ -122,8 +122,9 @@ public class NxtAR_bot{
|
||||
* Force quit.
|
||||
*/
|
||||
@Override
|
||||
public void buttonPressed(Button b) {
|
||||
quit();
|
||||
public void buttonPressed(Button b){
|
||||
System.exit(0);
|
||||
//quit();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -79,7 +79,7 @@ public class MotorControlThread extends Thread{
|
||||
message[1] = inputStream.readByte();
|
||||
|
||||
// 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;
|
||||
motorB = (message[0] & MotorMasks.MOTOR_B) > 0 ? true : false;
|
||||
motorC = (message[0] & MotorMasks.MOTOR_C) > 0 ? true : false;
|
||||
@@ -113,12 +113,12 @@ public class MotorControlThread extends Thread{
|
||||
}
|
||||
|
||||
if(recenterMotorB){
|
||||
// Return motor B to it's origin. Rotate in the direction
|
||||
// that implies less movement.
|
||||
System.out.println("RECENTER");
|
||||
// Return motor B to it's origin.
|
||||
Motor.B.setSpeed(50 * Battery.getVoltage());
|
||||
tacho = Motor.B.getTachoCount() % 360;
|
||||
rotation = tacho > 180 ? 360 - tacho : -(tacho);
|
||||
Motor.B.rotate(rotation);
|
||||
Motor.B.resetTachoCount();
|
||||
rotation = -(tacho);
|
||||
Motor.B.rotate(rotation, false);
|
||||
}
|
||||
|
||||
}catch(IOException io){
|
||||
|
||||
Reference in New Issue
Block a user