X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;ds=sidebyside;f=dsl%2Fruntime%2Fsrc%2Fnl%2Fru%2Fdes%2FBasicBehaviour.java;h=455cbe23dc03729faee920b9eb458f9d903e8ea7;hb=ac44621696b120a5aec35edff6b7181a4aafa383;hp=2de5ab36ddfb445a93e5b28cc63c5db637a24f93;hpb=095cdf6fc0cbad75c6057a401cbab23c18931a3d;p=des2015.git diff --git a/dsl/runtime/src/nl/ru/des/BasicBehaviour.java b/dsl/runtime/src/nl/ru/des/BasicBehaviour.java index 2de5ab3..455cbe2 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(); } @@ -61,8 +62,32 @@ public abstract class BasicBehaviour implements Behavior{ Thread.yield(); } measMotor.stop(true); - reset(); - rightTurn(45); + + turnRandom(30, 45); + } + + protected void measureRock(){ + long time = System.currentTimeMillis(); + rightMotor.forward(); + leftMotor.forward(); + while(System.currentTimeMillis()-time<1500){ + Thread.yield(); + } + + rightMotor.stop(true); + leftMotor.stop(true); + + measMotor.backward(); + while(!suppressed && !measMotor.isStalled()){ + Thread.yield(); + } + measMotor.forward(); + while(!suppressed && !measMotor.isStalled()){ + Thread.yield(); + } + measMotor.stop(true); + + turnRandom(30, 45); } protected void turnRandom(int from, int to){