final commit
[des2015.git] / dsl / runtime / src / nl / ru / des / BasicBehaviour.java
index 44fcbe2..945a709 100644 (file)
@@ -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