X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=dsl%2Fruntime%2Fsrc%2Fnl%2Fru%2Fdes%2FBasicBehaviour.java;h=945a70986b945a268298deb91de7bb3cb9d86cb4;hb=3e5a839d3f540c49d5b903bfebdd8913e7deef9a;hp=44fcbe2af0fada71e904e6a369fe04a0de7ac47a;hpb=8880a95aedaf51c028818910b64f85472d96c14e;p=des2015.git diff --git a/dsl/runtime/src/nl/ru/des/BasicBehaviour.java b/dsl/runtime/src/nl/ru/des/BasicBehaviour.java index 44fcbe2..945a709 100644 --- a/dsl/runtime/src/nl/ru/des/BasicBehaviour.java +++ b/dsl/runtime/src/nl/ru/des/BasicBehaviour.java @@ -29,13 +29,14 @@ public abstract class BasicBehaviour implements Behavior{ leftMotor.setAcceleration(Constants.acceleration); rightMotor.stop(true); leftMotor.stop(true); + measMotor.stop(true); } protected void measureLake(){ long time = System.currentTimeMillis(); rightMotor.backward(); leftMotor.backward(); - while(System.currentTimeMillis()-time<500){ + while(System.currentTimeMillis()-time < 250){ Thread.yield(); } @@ -44,32 +45,38 @@ public abstract class BasicBehaviour implements Behavior{ rightMotor.setSpeed(25); leftMotor.setSpeed(25); if(sensors.leftLight() && !sensors.rightLight()){ - leftTurn(15); + leftTurn(10); } else if (sensors.rightLight() && !sensors.leftLight()){ - rightTurn(15); + rightTurn(10); } rightMotor.stop(true); leftMotor.stop(true); - measMotor.backward(); - while(!suppressed && !measMotor.isStalled()){ + measMotor.rotate(-100, true); + while(!suppressed && !measMotor.isStalled() && measMotor.isMoving()){ Thread.yield(); } - measMotor.forward(); - while(!suppressed && !measMotor.isStalled()){ + measMotor.rotate(100, true); + while(!suppressed && !measMotor.isStalled() && measMotor.isMoving()){ Thread.yield(); } measMotor.stop(true); - turnRandom(30, 45); + reset(); + rightMotor.backward(); + leftMotor.backward(); + while(System.currentTimeMillis()-time < 250){ + Thread.yield(); + } + turnRandom(45, 60); } protected void measureRock(){ long time = System.currentTimeMillis(); rightMotor.forward(); leftMotor.forward(); - while(System.currentTimeMillis()-time<1500){ + while(System.currentTimeMillis()-time<1000){ Thread.yield(); } @@ -86,6 +93,11 @@ public abstract class BasicBehaviour implements Behavior{ } measMotor.stop(true); + rightMotor.backward(); + leftMotor.backward(); + while(System.currentTimeMillis()-time<1000){ + Thread.yield(); + } turnRandom(30, 45); } @@ -109,7 +121,7 @@ public abstract class BasicBehaviour implements Behavior{ } rightMotor.stop(true); leftMotor.stop(true); - LCDPrinter.print(Float.toString(sensors.gyro())); + System.out.println(Float.toString(sensors.gyro())); } protected void leftTurn(int angle){ @@ -123,7 +135,7 @@ public abstract class BasicBehaviour implements Behavior{ } rightMotor.stop(true); leftMotor.stop(true); - LCDPrinter.print(Float.toString(sensors.gyro())); + System.out.println(Float.toString(sensors.gyro())); } @Override