-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRangeTest.java
More file actions
45 lines (31 loc) · 982 Bytes
/
RangeTest.java
File metadata and controls
45 lines (31 loc) · 982 Bytes
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
package localisation;
import lejos.nxt.LCD;
import lejos.nxt.SensorPort;
import lejos.nxt.addon.OpticalDistanceSensor;
import lejos.util.Delay;
import rp.config.RobotConfigs;
import rp.config.WheeledRobotConfiguration;
import rp.systems.WheeledRobotSystem;
public class RangeTest{
private WheeledRobotSystem system;
private boolean running=true;
private OpticalDistanceSensor distanceSensor;
public RangeTest(WheeledRobotConfiguration config,OpticalDistanceSensor distanceSensor){
this.system= new WheeledRobotSystem(config);
this.distanceSensor=distanceSensor;
}
public static void main(String[] args){
RangeTest rangeTest = new RangeTest((WheeledRobotConfiguration) RobotConfigs.CASTOR_BOT,new OpticalDistanceSensor(SensorPort.S2));
rangeTest.run();
}
public void run() {
while(running){
LCD.drawString(String.valueOf(distanceSensor.getRange()), 0, 0);
Delay.msDelay(50);
}
}
public void stop()
{
running =false;
}
}