3 import lejos
.hardware
.Sound
;
4 import lejos
.hardware
.motor
.EV3LargeRegulatedMotor
;
5 import lejos
.robotics
.subsumption
.Behavior
;
7 public class WandererBehaviour
implements Behavior
{
8 private EV3LargeRegulatedMotor leftMotor
, rightMotor
;
9 private ColorSensor colorSensor
;
10 private boolean suppressed
;
11 private ColorMemory cm
;
13 public WandererBehaviour(ColorSensor colorSensor
, EV3LargeRegulatedMotor leftMotor
,
14 EV3LargeRegulatedMotor rightMotor
, ColorMemory cm
) {
15 this.leftMotor
= leftMotor
;
16 this.rightMotor
= rightMotor
;
17 this.colorSensor
= colorSensor
;
22 public boolean takeControl() {
23 return !cm
.finished();
27 public void action() {
29 leftMotor
.setSpeed(300);
30 rightMotor
.setSpeed(300);
34 String current
= colorSensor
.getCurrentColor();
35 if (current
== "Yellow" || current
== "Blue" || current
== "Red") {
37 BTController
.SendMessage(current
);
42 rightMotor
.stop(true);
46 public void suppress() {