-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocalisation.java
More file actions
56 lines (47 loc) · 1.78 KB
/
Localisation.java
File metadata and controls
56 lines (47 loc) · 1.78 KB
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
package localisation;
import java.awt.Point;
import Objects.Direction;
import lejos.nxt.LightSensor;
import lejos.nxt.Motor;
import lejos.nxt.SensorPort;
import lejos.nxt.addon.OpticalDistanceSensor;
import lejos.robotics.navigation.DifferentialPilot;
import lejos.robotics.subsumption.Arbitrator;
import lejos.robotics.subsumption.Behavior;
import rp.config.WheeledRobotConfiguration;
import rp.robotics.DifferentialDriveRobot;
import rp.robotics.mapping.MapUtils;
//Main class
public class Localisation {
private Behavior junction;
private Behavior line;
private Arbitrator arby;
public static ProbableLocations locs;
public static float heading;
public Localisation(){
super();
final double speed = 0.18;
final int threshold = 42;
WheeledRobotConfiguration OUR_BOT = new WheeledRobotConfiguration(0.056f, 0.120f, 0.230f, Motor.B, Motor.C);
DifferentialPilot pilot = new DifferentialDriveRobot(OUR_BOT).getDifferentialPilot();
LightSensor left = new LightSensor(SensorPort.S1);
LightSensor right = new LightSensor(SensorPort.S3);
OpticalDistanceSensor range = new OpticalDistanceSensor(SensorPort.S2);
locs = new ProbableLocations(MapUtils.createMarkingWarehouseMap());
line = new LineFollow(pilot, left, right, speed, threshold);
junction = new JunctionDetection(pilot, left, right, speed, range, threshold);
arby = new Arbitrator(new Behavior[] {line,junction}, true);
arby.start();
}
public int getSize(){
//ProbableLocations locs = ((JunctionDetection)junction).getLocs();
return locs.size();
}
public Point getPoint(){
//ProbableLocations locs = ((JunctionDetection)junction).getLocs();
return new Point(locs.getPoints(0).getxCoord(), locs.getPoints(0).getyCoord());
}
public Direction getDir(){
return ((JunctionDetection)junction).getDir();
}
}