-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChangeDirection.java
58 lines (48 loc) · 1.16 KB
/
ChangeDirection.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import lejos.nxt.LightSensor;
import lejos.nxt.UltrasonicSensor;
import lejos.robotics.navigation.DifferentialPilot;
import lejos.robotics.subsumption.Behavior;
/**
* Currently change direction to the left
*
* @author BhuONE
*/
public class ChangeDirection implements Behavior
{
private DifferentialPilot pilot;
private LightSensor lightSensor;
private UltrasonicSensor ultrasonicSensor;
private boolean suppressed = false;
public ChangeDirection(final DifferentialPilot pilot,
final LightSensor lightSensor)
{
this.pilot = pilot;
this.lightSensor = lightSensor;
}
// public ChangeDirection(final DifferentialPilot pilot,
// final LightSensor lightSensor,
// final UltrasonicSensor ultrasonicSensor)
// {
// this.pilot = pilot;
// this.lightSensor = lightSensor;
// this.ultrasonicSensor = ultrasonicSensor;
// }
@Override
public boolean takeControl()
{
return lightSensor.getLightValue() < 26;
}
@Override
public void action()
{
suppressed = false;
// steer left
// pilot.steer(30, 20);
pilot.rotate(25);
}
@Override
public void suppress()
{
suppressed = true;
}
}