package nl.ru.des;
-import java.io.File;
-
import lejos.hardware.motor.EV3LargeRegulatedMotor;
import lejos.hardware.sensor.EV3TouchSensor;
import lejos.robotics.SampleProvider;
public class AvoidLowObjectBehaviour extends AvoidBehaviour {
private SampleProvider rightSample, leftSample;
private float[] samples;
- private long lastPush = 0;
public AvoidLowObjectBehaviour(EV3LargeRegulatedMotor leftMotor, EV3LargeRegulatedMotor rightMotor,
EV3TouchSensor leftTouch, EV3TouchSensor rightTouch) {
- super(leftMotor, rightMotor, new File("bump.wav"));
+ super(leftMotor, rightMotor, "bump.wav");
rightSample = rightTouch.getTouchMode();
leftSample = leftTouch.getTouchMode();
samples = new float[rightTouch.sampleSize()];
if(samples[0] == 1){
super.setAvoidDirection(false);
takeControl = true;
- lastPush = System.currentTimeMillis();
}
//Check if right sensor is pressed
if(samples[0] == 1){
super.setAvoidDirection(true);
takeControl = true;
- lastPush = System.currentTimeMillis();
}
- return takeControl || System.currentTimeMillis()-lastPush < 1000;
+ return takeControl;
}
@Override