import lejos.hardware.motor.EV3LargeRegulatedMotor;
import lejos.robotics.subsumption.Behavior;
+import nl.ru.des.sensors.SensorCollector;
public abstract class BasicBehaviour implements Behavior{
protected boolean suppressed;
protected EV3LargeRegulatedMotor leftMotor, rightMotor;
protected SensorCollector sensors;
- protected ColorMemory colors;
protected long time;
public BasicBehaviour(SensorCollector sensors, EV3LargeRegulatedMotor leftMotor,
- EV3LargeRegulatedMotor rightMotor, ColorMemory colors){
+ EV3LargeRegulatedMotor rightMotor){
this.leftMotor = leftMotor;
this.rightMotor = rightMotor;
- this.colors = colors;
this.sensors = sensors;
}
+++ /dev/null
-package nl.ru.des;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import lejos.robotics.SampleProvider;
-
-public class ColorMemory {
-
- private Set<Integer> colors;
-
- public ColorMemory(SampleProvider color) {
- colors = new HashSet<Integer>();
- }
-
- public void addColor(int current) {
- if(!colors.contains(current)){
- colors.add(current);
- }
- }
- public boolean containsAll(List<Integer> is) {
- return colors.containsAll(is);
- }
-
-}
package nl.ru.des;
-import java.util.Queue;
-
import lejos.hardware.Button;
import lejos.hardware.ev3.EV3;
import lejos.hardware.ev3.LocalEV3;
import lejos.hardware.sensor.NXTLightSensor;
import lejos.robotics.SampleProvider;
import lejos.robotics.subsumption.Arbitrator;
+import nl.ru.des.sensors.BTController;
+import nl.ru.des.sensors.RemoteSensors;
+import nl.ru.des.sensors.SensorCollector;
public class Marster {
public static Arbitrator arb;
SampleProvider color = new EV3ColorSensor(brick.getPort("S4")).getColorIDMode();
RemoteSensors rs = new RemoteSensors(leftTouch, rightTouch, frontUltra, color);
- LCDPrinter.print("Start BT...");
- Queue<String> msgs = BTController.startSlave();
- rs.start(msgs);
+ LCDPrinter.print("Start BT... Press any key to commence");
+ Button.waitForAnyEvent();
+ BTController.startSlave();
+ rs.start(BTController.buf);
} else {
LCDPrinter.print("Starting as as master...");
LCDPrinter.print("Loading motors...");
LCDPrinter.print("Loading gyro sensor...");
SampleProvider gyro = new EV3GyroSensor(brick.getPort("S4")).getAngleAndRateMode();
- LCDPrinter.print("Start BT...");
+ LCDPrinter.print("Start BT... Press any key to commence");
+ Button.waitForAnyEvent();
BTController.startMaster(brick.getName() == "Rover5" ? "Rover6" : "Rover8", new SensorCollector(backUltra, leftLight, rightLight, gyro));
LCDPrinter.print("Finished loading");
Button.waitForAnyPress();
package nl.ru.des;
import lejos.hardware.motor.EV3LargeRegulatedMotor;
+import nl.ru.des.sensors.SensorCollector;
public class ShutdownBehaviour extends BasicBehaviour{
public ShutdownBehaviour(SensorCollector sensors, EV3LargeRegulatedMotor leftMotor,
- EV3LargeRegulatedMotor rightMotor, ColorMemory colors) {
- super(sensors, leftMotor, rightMotor, colors);
+ EV3LargeRegulatedMotor rightMotor) {
+ super(sensors, leftMotor, rightMotor);
}
@Override public void action(){
-package nl.ru.des;
+package nl.ru.des.sensors;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import lejos.remote.nxt.NXTConnection;
public class BTController{
+ public static Queue<String> buf;
+ public static DataInputStream dataIn;
+ public static DataOutputStream dataOut;
+
public static void startMaster(final String slave, final MessageHandler sh) {
BTConnector btconnector = new BTConnector();
NXTConnection conn = btconnector.connect(slave, NXTConnection.RAW);
- final DataInputStream dataInput = conn.openDataInputStream();
+ dataOut = conn.openDataOutputStream();
+ dataIn = conn.openDataInputStream();
new Thread() {
@Override
public void run() {
StringBuilder sb = new StringBuilder();
while (true) {
try {
- int c = dataInput.readUnsignedByte();
+ int c = dataIn.readUnsignedByte();
if (c == '\n') {
sh.handleMessage(sb.toString());
sb = new StringBuilder();
}.start();
}
- public static Queue<String> startSlave() {
+ public static void startSlave() {
BTConnector btconnector = new BTConnector();
NXTConnection conn = btconnector.waitForConnection(60000, NXTConnection.RAW);
- final DataOutputStream dataOutput = conn.openDataOutputStream();
- final Queue<String> buf = new LinkedList<String>();
+ dataIn = conn.openDataInputStream();
+ dataOut = conn.openDataOutputStream();
+ buf = new LinkedList<String>();
new Thread(){
@Override public void run(){
while (true) {
if (!buf.isEmpty()) {
try {
- dataOutput.write(buf.poll().getBytes());
- dataOutput.flush();
+ dataOut.write(buf.poll().getBytes());
+ dataOut.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}.start();
- return buf;
}
}
\ No newline at end of file
-package nl.ru.des;
+package nl.ru.des.sensors;
public interface MessageHandler {
public void handleMessage(String message);
-package nl.ru.des;
+package nl.ru.des.sensors;
import java.util.Queue;
import lejos.robotics.SampleProvider;
+import nl.ru.des.LCDPrinter;
public class RemoteSensors{
public static final int DELAY = 250;
private float[] leftSamples, rightSamples, ultraSamples, colorSamples;
private float leftLatest, rightLatest, ultraLatest, colorLatest;
- public enum RemoteSensorEnum{
+ public enum RemoteSensorEnum {
LEFT, RIGHT, ULTRA, COLOR;
}
-package nl.ru.des;
+package nl.ru.des.sensors;
import lejos.robotics.SampleProvider;
@Override
public void handleMessage(String m) {
- LCDPrinter.print(m);
String s = m.substring(1);
- switch(RemoteSensors.RemoteSensorEnum.values()[Integer.valueOf(m.charAt(0))]){
+ switch(RemoteSensors.RemoteSensorEnum.values()[Integer.valueOf(Character.toString(m.charAt(0)))]){
case COLOR:
color = Integer.valueOf(s);
break;
phase, and a design phase. Furthermore, each of the iterations will have goals
and results. The iterations and their deliverables are listed in
\autoref{tab:devit}. The schedule for finishing iterations are listed in
-\autoref{tab:deadli}. On the 23rd of december the must should be finished and
-if they are we try to complete as many iterations as possible.
+\autoref{tab:deadli}. On the 6th of January the must-have should be finished
+and if they are we try to complete as many iterations as possible.
\begin{table}[h!]
\centering
\begin{tabu} to \linewidth{llX}
\toprule
Deadline & Iterations\\
\midrule
- 3 Dec 2015 & 1--2\\
- 9 Dec 2015 & 3--5\\
- 16 Dec 2015 & 6--9\\
- 23 Dec 2015 & 10--11\\
+ 9 Dec 2015 & 1--2\\
+ 16 Dec 2015 & 3--5\\
+ 23 Dec 2015 & 6--9\\
+ 6 Jan 2015 & 10--11\\
+ 13 Jan 2015 & Demo\\
\bottomrule
\end{tabu}
\caption{Deadlines}\label{tab:deadli}