-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReverseRight.java
53 lines (44 loc) · 1017 Bytes
/
ReverseRight.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
import lejos.nxt.LightSensor;
import lejos.nxt.TouchSensor;
import lejos.robotics.navigation.DifferentialPilot;
import lejos.robotics.subsumption.Behavior;
/**
* If bumps into wall, reverse and turn right
*
* @author BhuONE
*/
public class ReverseRight implements Behavior
{
private boolean suppressed = false;
private TouchSensor bumper;
private DifferentialPilot pilot;
// private LightSensor lightSensor;
public ReverseRight(final DifferentialPilot pilot, final TouchSensor bumper)
{
this.bumper = bumper;
this.pilot = pilot;
}
// public ReverseRight(final DifferentialPilot pilot,
// final LightSensor lightSensor)
// {
// this.pilot = pilot;
// this.lightSensor = lightSensor;
// }
@Override
public boolean takeControl()
{
return bumper.isPressed();
}
@Override
public void action()
{
suppressed = false;
pilot.travel(-5);
pilot.rotate(-90);
}
@Override
public void suppress()
{
suppressed = true;
}
}