From: Mart Lubbers Date: Thu, 10 Dec 2015 15:33:10 +0000 (+0100) Subject: push X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=16aef029cf49685c60c422d36b54d459355e832c;p=des2015.git push --- diff --git a/dsl/runtime/specs/wander.tdsl b/dsl/runtime/specs/wander.tdsl index 5100e52..a51a064 100644 --- a/dsl/runtime/specs/wander.tdsl +++ b/dsl/runtime/specs/wander.tdsl @@ -16,15 +16,11 @@ Behaviour StayInFieldBoth Behaviour StayInFieldL take control: Light on left action: - right motor backward with speed 250 acceleration 10000 - left motor forward with speed 250 acceleration 10000 - wait 750 ms + turn right 90 with speed 100 acceleration 10000 Behaviour StayInFieldR take control: Light on right action: - right motor forward with speed 250 acceleration 10000 - left motor backward with speed 250 acceleration 10000 - wait 750 ms + turn left 90 with speed 100 acceleration 10000 Behaviour StayInFieldB take control: Distance dangerous at back action: diff --git a/dsl/runtime/src/nl/ru/des/BasicBehaviour.java b/dsl/runtime/src/nl/ru/des/BasicBehaviour.java index 1d79edd..9b7742b 100644 --- a/dsl/runtime/src/nl/ru/des/BasicBehaviour.java +++ b/dsl/runtime/src/nl/ru/des/BasicBehaviour.java @@ -5,7 +5,7 @@ import lejos.robotics.subsumption.Behavior; import nl.ru.des.sensors.SensorCollector; public abstract class BasicBehaviour implements Behavior{ - protected boolean suppressed; + protected int suppressed; protected RegulatedMotor leftMotor, rightMotor, measMotor; protected SensorCollector sensors; protected long time; @@ -25,6 +25,7 @@ public abstract class BasicBehaviour implements Behavior{ leftMotor.setAcceleration(Constants.acceleration); rightMotor.stop(true); leftMotor.stop(true); + suppressed = 0; } protected void rockMeasure(){ @@ -36,25 +37,35 @@ public abstract class BasicBehaviour implements Behavior{ } protected void rightTurn(int angle){ - + float init = sensors.gyro(); + rightMotor.backward(); + leftMotor.forward(); + + while(suppressed != 2 && sensors.gyro()-90>init){ + Thread.yield(); + } } protected void leftTurn(int angle){ - + float init = sensors.gyro(); + leftMotor.backward(); + rightMotor.forward(); + while(suppressed != 2 && sensors.gyro()+90DELAY){ diff --git a/dsl/xtend/src/robots/missions/generator/TaskDSLGenerator.xtend b/dsl/xtend/src/robots/missions/generator/TaskDSLGenerator.xtend index e57aea6..b4c56ae 100644 --- a/dsl/xtend/src/robots/missions/generator/TaskDSLGenerator.xtend +++ b/dsl/xtend/src/robots/missions/generator/TaskDSLGenerator.xtend @@ -10,8 +10,8 @@ import org.eclipse.xtext.generator.IGenerator import robots.missions.taskDSL.Behaviour import robots.missions.taskDSL.Mission import robots.missions.taskDSL.OperatorE -import robots.missions.taskDSL.Robot import robots.missions.taskDSL.StoppingExpression +import robots.missions.taskDSL.Robot /** * Generates code from your model files on save. @@ -73,7 +73,7 @@ public class «b.name»Behaviour extends BasicBehaviour { } «IF b.tc != null» @Override public boolean takeControl(){ - return !suppressed || «printExpression(b.tc)»; + return suppressed == 1 || «printExpression(b.tc)»; } «ENDIF» @@ -89,10 +89,16 @@ public class «b.name»Behaviour extends BasicBehaviour { «ELSEIF a.measureWhat != null» «a.measureWhat.d.toString()»Measure(); «ELSEIF a.turnDir != null» + «IF a.acc > 0» + leftMotor.setAcceleration(«a.acc»); + leftMotor.setSpeed(«a.spd»); + rightMotor.setAcceleration(«a.acc»); + rightMotor.setSpeed(«a.spd»); + «ENDIF» «a.turnDir.d.toString()»Turn(«a.degrees»); «ELSE» time = System.currentTimeMillis(); - while(!suppressed«IF a.time.time > 0» && System.currentTimeMillis()-time>«a.time.time»«ENDIF»){ + while(suppressed != 2«IF a.time.time > 0» && System.currentTimeMillis()-time>«a.time.time»«ENDIF»){ Thread.yield(); } «ENDIF»