wait 1000 ms
Behaviour GreenLake
- take control: (&& Color is Green not flag set GreenMeasured)
+ take control: (&& (|| Color is Green Color is Yellow) not flag set GreenLake)
action:
measure Lake
set flag GreenLake
Behaviour BlueLake
- take control: (&& Color is Blue not flag set BlueMeasured)
+ take control: (&& Color is Blue not flag set BlueLake)
action:
measure Lake
set flag BlueLake
Behaviour RedLake
- take control: (&& Color is Red not flag set RedMeasured)
+ take control: (&& Color is Red not flag set RedLake)
action:
measure Lake
set flag RedLake
action:
measure Rock
set flag Measured
+
+Behaviour AvoidL
+ take control: Touched on left
+ action:
+ left motor forward
+ right motor backward
+
+Behaviour AvoidR
+ take control: Touched on right
+ action:
+ right motor forward
+ left motor backward
Behaviour PushL
take control: Touched on left
action:
right motor forward
- left motor backward
+ left motor forward with speed 50 acceleration 1000
Behaviour PushR
take control: Touched on right
action:
left motor forward
- right motor backward
+ right motor forward with speed 50 acceleration 1000
Behaviour PushB
take control: (&& Touched on left Touched on right)
Behaviour StopPushing
take control: (&& not Touched on left not Touched on right flag set Pushing)
action:
+ left motor backward
+ right motor backward
+ wait 1000ms
+ turn left exactly 180 degrees
set flag Pushed
Behaviour FoundLineL
- take control: Light on left
+ take control: (&& (|| not flag set LeftLine not flag set RightLine) Light on left not Light on right Color is Black)
action:
+ left motor backward with speed 75 acceleration 1000
+ right motor backward with speed 75 acceleration 1000
+ wait 1000 ms
set flag LeftLine
Behaviour FoundLineR
- take control: Light on right
+ take control: (&& (|| not flag set LeftLine not flag set RightLine) Light on right not Light on left Color is Black)
action:
+ left motor backward with speed 75 acceleration 1000
+ right motor backward with speed 75 acceleration 1000
+ wait 1000 ms
set flag RightLine
Behaviour FollowLGood
take control: (&& flag set LeftLine Light on left)
action:
left motor forward with speed 75 acceleration 1000
- right motor backward with speed 50 acceleration 1000
+ right motor backward with speed 60 acceleration 1000
Behaviour FollowLBad
take control: (&& flag set LeftLine not Light on left)
take control: (&& flag set RightLine Light on right)
action:
right motor forward with speed 75 acceleration 1000
- left motor backward with speed 50 acceleration 1000
+ left motor backward with speed 60 acceleration 1000
Behaviour FollowRBad
take control: (&& flag set RightLine not Light on right)
left motor forward with speed 100 acceleration 1000
Behaviour FoundParkingSpace
- take control: (&& (|| flag set LeftLine flag set RightLine) Color is White)// (|| Light on left Light on right))
+ take control: (&& (|| flag set LeftLine flag set RightLine) Color is White)
action:
set flag Parked
- /*
-Mission FindAndMeasureLakes
- using Wander StayInFieldR StayInFieldL StayInFieldB GreenLake RedLake BlueLake
- and stops when (&& flag set GreenLake flag set RedLake flag set BlueLake)
Mission FindAndMeasureRocks
- using Wander StayInFieldR StayInFieldL StayInFieldB MeasureRock
+ using Drive StayInFieldR StayInFieldL StayInFieldB AvoidL AvoidR MeasureRock
and stops when flag set Measured
+Mission FindAndMeasureLakes
+ using Drive StayInFieldR StayInFieldL StayInFieldB AvoidL AvoidR GreenLake RedLake BlueLake
+ and stops when (&& flag set GreenLake flag set RedLake flag set BlueLake)
Mission PushRocks
- using Wander PushL PushR PushB StopPushing StayInFieldR StayInFieldL StayInFieldB
- and stops when flag set Pushed*/
+ using Drive PushL PushR PushB StayInFieldR StayInFieldL StayInFieldB StopPushing
+ and stops when flag set Pushed
Mission Park
- using Drive FoundLineL FoundLineR FollowLBad FollowLGood FollowRBad FollowRGood FoundParkingSpace
+ using Drive FoundLineL FoundLineR FollowLBad FollowLGood FollowRBad FollowRGood StayInFieldB FoundParkingSpace
and stops when flag set Parked
\ No newline at end of file
package nl.ru.des;
+import java.io.File;
import java.io.PrintStream;
import java.util.LinkedList;
import java.util.Random;
-import lejos.hardware.Button;
import lejos.hardware.Sound;
import lejos.hardware.ev3.EV3;
import lejos.hardware.ev3.LocalEV3;
import lejos.hardware.sensor.NXTLightSensor;
import lejos.robotics.RegulatedMotor;
import lejos.robotics.SampleProvider;
+import lejos.utility.Delay;
import nl.ru.des.sensors.BTController;
import nl.ru.des.sensors.RemoteSensors;
import nl.ru.des.sensors.SensorCollector;
public static Arbitrator arb;
public static Random random;
+ public static void playPacman(){
+ int whole = 2000;
+ Sound.playNote(Sound.PIANO, 494, whole/16);// b4
+ Sound.playNote(Sound.PIANO, 988, whole/16);// b5
+ Sound.playNote(Sound.PIANO, 740, whole/16);// f#5
+ Sound.playNote(Sound.PIANO, 622, whole/16);// eb5
+ Sound.playNote(Sound.PIANO, 988, whole/32);// b5
+ Sound.playNote(Sound.PIANO, 740, whole/16+whole/32);// f#5
+ Sound.playNote(Sound.PIANO, 622, whole/8);// eb5
+
+ Sound.playNote(Sound.PIANO, 523, whole/16);// c5
+ Sound.playNote(Sound.PIANO, 1047, whole/16);// c6
+ Sound.playNote(Sound.PIANO, 784, whole/16);// g5
+ Sound.playNote(Sound.PIANO, 659, whole/16);// e5
+ Sound.playNote(Sound.PIANO, 1047, whole/32);// c6
+ Sound.playNote(Sound.PIANO, 784, whole/16+whole/32);// g5
+ Sound.playNote(Sound.PIANO, 659, whole/8);// e5
+
+ Sound.playNote(Sound.PIANO, 494, whole/16);// b4
+ Sound.playNote(Sound.PIANO, 988, whole/16);// b5
+ Sound.playNote(Sound.PIANO, 740, whole/16);// f#5
+ Sound.playNote(Sound.PIANO, 622, whole/16);// eb5
+ Sound.playNote(Sound.PIANO, 988, whole/32);// b5
+ Sound.playNote(Sound.PIANO, 740, whole/16+whole/32);// f#5
+ Sound.playNote(Sound.PIANO, 622, whole/8);// eb5
+
+ Sound.playNote(Sound.PIANO, 622, whole/32);// eb5
+ Sound.playNote(Sound.PIANO, 659, whole/32);// e5
+ Sound.playNote(Sound.PIANO, 698, whole/16);// f5
+ Sound.playNote(Sound.PIANO, 698, whole/32);// f5
+ Sound.playNote(Sound.PIANO, 740, whole/32);// f#5
+ Sound.playNote(Sound.PIANO, 784, whole/16);// g5
+ Sound.playNote(Sound.PIANO, 784, whole/32);// g5
+ Sound.playNote(Sound.PIANO, 831, whole/32);// ab5
+ Sound.playNote(Sound.PIANO, 880, whole/16);// a5
+ Sound.playNote(Sound.PIANO, 988, whole/8);// b5
+ }
+
@SuppressWarnings("resource")
public static void main(String[] args) {
EV3 brick = LocalEV3.get();
System.out.println("Loading keylistener...");
brick.getKey("Escape").addKeyListener(new ButtonListener());
-
if(brick.getName().equalsIgnoreCase("Rover6") || brick.getName().equalsIgnoreCase("Rover8")){
System.out.println("Starting as a slave...");
System.out.println("My name is " + brick.getName());
sc.calibrate();
LinkedList<Mission> missions = Missions.getMissions(sc, rightMotor, leftMotor, measMotor);
random = new Random();
- System.out.println("Press any button to start");
- Button.waitForAnyEvent();
+ Delay.msDelay(2000);
+ playPacman();
for(Mission m : missions){
System.out.println("Start " + m.name + " mission...");
arb = new Arbitrator(m.behaviours);
sc.reset();
arb.start();
Sound.buzz();
+ Delay.msDelay(5000);
System.out.println(m.name + " finished!!1one!");
}
+ Sound.playSample(new File("rick.wav"), Sound.VOL_MAX);
System.exit(0);
}
}