+++ /dev/null
--Acceleration 1000
-Speed 200
-Behaviour Wander
- take control:
- action:
- left motor forward
- right motor forward
- wait forever
- measure lake
- measure rock
-Behaviour AvoidLowLeftObjects
- take control: Touched on left
- action:
- left motor backward
- right motor backward
- wait 250 ms
- right motor backward
- left motor forward
- wait 250 ms
-Behaviour AvoidLowRightObjects
- take control: Touched on right
- action:
- left motor backward
- right motor backward
- wait 250 ms
- right motor forward
- left motor backward
- wait 250 ms
-Behaviour AvoidHighObjects
- take control:
- action:
- right motor forward
- wait 250 ms
-Behaviour StayInLine
- take control: Color is Black
- action:
- right motor forward
- left motor backward
- wait 250 ms
-Behaviour Measure
- take control:
- action:
- measure rock
- wait 250 ms
-Mission Assignment
-using
- Wander
- AvoidLowLeftObjects
- AvoidLowRightObjects
- AvoidHighObjects
- StayInLine
-and stops when
- Collected at least Blue Green Yellow
\ No newline at end of file
Acceleration 1000
Speed 150
+Behaviour Drive
+ take control:
+ action:
+ left motor forward
+ right motor forward
+ wait forever
Behaviour Wander
take control:
action:
Behaviour MeasureLake
take control: (|| Color is Green Color is Blue Color is Red)
action:
- measure
+ measure Lake
+
+Behaviour LocateL
+ take control: Touched on left
+ action:
+ right motor forward
+ left motor backward
+ wait 500 ms
+ right motor forward
+ left motor forward
+ wait 1000 ms
+
+Behaviour LocateR
+ take control: Touched on right
+ action:
+ left motor forward
+ right motor backward
+ wait 500 ms
+ right motor forward
+ left motor forward
+ wait 1000 ms
+
+Behaviour Push
+ take control: (&& Touched on left Touched on right)
+ action:
+ left motor forward
+ right motor forward
+ wait 1000 ms
Behaviour BumpL
take control: Touched on left
right motor backward with speed 50 acceleration 1000
left motor backward
wait 2000 ms
+
+Behaviour AvoidHigh
+ take control: Distance dangerous at front
+ action:
+ turn randomly 10 to 11 degrees
-Mission findBlueLakeWhileAvoidingRocks
- using Wander BumpR BumpL StayInFieldB StayInFieldL StayInFieldR and stops when Color is Blue
-Mission findAllLakesAndMeasureThem
- using Wander MeasureLake StayInFieldB StayInFieldL StayInFieldR and stops when Collected at least Green Blue Red
-Mission justWander
- using Wander StayInFieldB StayInFieldL StayInFieldR and stops when Color is Cyan
\ No newline at end of file
+//Mission pushRock
+// using Drive LocateR LocateL Push StayInFieldB StayInFieldL StayInFieldR and stops when Never
+Mission avoidHighRocks
+ using Drive AvoidHigh BumpR BumpL StayInFieldB StayInFieldL StayInFieldR and stops when Never
+//Mission measureLake
+// using Drive MeasureLake and stops when Never
+//Mission findBlueLakeWhileAvoidingRocks
+// using Wander BumpR BumpL StayInFieldB StayInFieldL StayInFieldR and stops when Color is Blue
+//Mission findAllLakesAndMeasureThem
+// using Wander MeasureLake StayInFieldB StayInFieldL StayInFieldR and stops when Collected at least Green Blue Red
+//Mission justWander
+// using Wander Wander StayInFieldB StayInFieldL StayInFieldR and stops when Color is Cyan
\ No newline at end of file
leftMotor.stop(true);
}
- protected void measure(){
+ protected void measureLake(){
+ long time = System.currentTimeMillis();
+ rightMotor.backward();
+ leftMotor.backward();
+ while(System.currentTimeMillis()-time<500){
+ Thread.yield();
+ }
+
+ rightMotor.stop(true);
+ leftMotor.stop(true);
+ rightMotor.setSpeed(25);
+ leftMotor.setSpeed(25);
+ if(sensors.leftLight() && !sensors.rightLight()){
+ leftTurn(15);
+ } else if (sensors.rightLight() && !sensors.leftLight()){
+ rightTurn(15);
+ }
+
+ rightMotor.stop(true);
+ leftMotor.stop(true);
+
measMotor.backward();
while(!suppressed && !measMotor.isStalled()){
Thread.yield();
Thread.yield();
}
measMotor.stop(true);
- rightTurn(90);
+ reset();
+ rightTurn(45);
}
protected void turnRandom(int from, int to){
public void action() {
suppressed = false;
finished = false;
+ rightMotor.setSpeed(Constants.speed);
+ rightMotor.setAcceleration(Constants.acceleration);
+ leftMotor.setSpeed(Constants.speed);
+ leftMotor.setAcceleration(Constants.acceleration);
+ rightMotor.stop(true);
+ leftMotor.stop(true);
}
@Override
public void suppress() {
suppressed = true;
finished = true;
+ rightMotor.setSpeed(Constants.speed);
+ rightMotor.setAcceleration(Constants.acceleration);
+ leftMotor.setSpeed(Constants.speed);
+ leftMotor.setAcceleration(Constants.acceleration);
+ rightMotor.stop(true);
+ leftMotor.stop(true);
}
@Override public boolean takeControl(){
public class SensorCollector implements MessageHandler{
public static final int DELAY = 200;
- private static final float DANGER_DISTANCE_FRONT = 0.15f;
+ private static final float DANGER_DISTANCE_FRONT = 0.175f;
private static final float DANGER_DISTANCE_BACK = 0.035f;
- private static final float DANGER_LIGHT = 0.45f;
+ private static final float DANGER_LIGHT = 0.40f;
private Set<Integer> collectedColors;
rightLightTime = System.currentTimeMillis();
gyroTime = System.currentTimeMillis();
+ color = -1;
+ leftTouch = false;
+ rightTouch = false;
+ frontUltra = Float.MAX_VALUE;
collectedColors = new HashSet<Integer>();
}
'Touched on' touch=LeftRight |
'Light on' light=LeftRight |
'Distance dangerous at ' dist=BackFront |
- 'Color is' color=Color;
+ 'Color is' color=Color |
+ {StoppingCondition} 'Never';
Behaviour: 'Behaviour' name=ID
'take control:' tc=StoppingExpression?
Action:
whichMotor=LeftRight 'motor' moveDir=Direction ('with speed' spd=INT 'acceleration' acc=INT)? |
'turn' turnType=Turn ('with speed' spd=INT 'acceleration' acc=INT)? |
- {Action} 'measure'|
+ 'measure' rl=RockLake|
'wait' time=Time;
Turn:
Time: time=INT 'ms' | {Time} 'forever';
RockLake: d=RockLakeE;
-enum RockLakeE: ROCK='rock' | LAKE='lake';
+enum RockLakeE: ROCK='Rock' | LAKE='Lake';
Direction: d=DirectionE;
enum DirectionE: BACKWARDS = 'backward' | FORWARDS = 'forward';
Operator: d=OperatorE;
turnRandom(«a.turnType.start», «a.turnType.end»);
«ENDIF»
«ELSE»
- measure();
+ measure«a.rl.d.toString()»();
«ENDIF»
«ENDFOR»
LCDPrinter.print("Stop: «b.name»");
- reset();
}
}
'''
sensors.«e.scond.dist.d.toString()»Distance()
«ELSEIF e.scond.color != null»
sensors.color() == «e.scond.color.d.ordinal»
+ «ELSE»
+ false
«ENDIF»
«ELSEIF e.negscond != null»
!(«printExpression(e.negscond)»)
«FOR ex : e.s BEFORE "(" SEPARATOR "&&" AFTER ")"»«printExpression(ex)»«ENDFOR»
«ELSE»
«FOR ex : e.s BEFORE "(" SEPARATOR "||" AFTER ")"»«printExpression(ex)»«ENDFOR»
- «ENDIF»
+ «ENDIF»
«ENDIF»'''
}
\ No newline at end of file
* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation
*/
class TaskDSLValidator extends AbstractTaskDSLValidator {
-
-// public static val INVALID_NAME = 'invalidName'
-//
// @Check
-// def checkGreetingStartsWithCapital(Greeting greeting) {
-// if (!Character.isUpperCase(greeting.name.charAt(0))) {
-// warning('Name should start with a capital',
-// MyDslPackage.Literals.GREETING__NAME,
-// INVALID_NAME)
+// def checkOnlyOneBehaviourPerMissionEmptyTakeControl(Mission m) {
+// var List<String> empty = new LinkedList<String>();
+// var List<String> all = new LinkedList<String>();
+// for(Behaviour b : m.behaviours){
+// if(b.tc == null){
+// empty.add(b.name);
+// }
+// all.add(b.name);
+// }
+// if(empty.size > 1){
+// warning("Multiple behaviours without takeControl predicate. You might want to remove some of: " + empty.toString(), m.eContainingFeature);
+// }
+// if(all.toSet().size() < all.size()){
+// warning("You have duplicate behaviours.", m, TaskDSLPackage.Literals::MISSION__BEHAVIOURS);
// }
// }
-/* @Check
- def checkStoppingExpressionShouldHaveOneBehaviourToCollectColor(Mission mission) {
- var isCollectColorExist = false;
- if (!mission.se.scond.colors.nullOrEmpty) {
- var blist = mission.behaviours;
- for (var j = 0; j < blist.size; j++) {
- if (!blist.get(j).clcColor.nullOrEmpty) {
- isCollectColorExist = true;
- }
- }
- }
- if (!isCollectColorExist) {
- error("Must specify one behaviour to collect color", null)
- }
- }*/
+
+//Validate if the random degrees are correct
}