1 package simworldobjects;
2
3 import interfaces.*;
4
5
10 public class SimTouchSensor extends SimSensor
11 {
12 private SimRCX robot;
13 private double xOffset, zOffset;
14
15
23 public SimTouchSensor(SimRCX r, double xOffset, double zOffset)
24 {
25 robot=r;
26 initSimSensor(r,xOffset,zOffset,10.0,10.0,10.0,"sensor");
27 this.xOffset=xOffset;
28 this.zOffset=zOffset;
29 }
30
31
37 public int getValue()
38 {
39 SimWorld world=robot.getWorld();
40
41 if (world.hasObstacle(this.getXCoord(),this.getYCoord(),this.getZCoord()))
42 {
43 return 1;
44 }
45 else
46 {
47 return 0;
48 }
49 }
50
51 public double getXOffset()
52 {
53 return xOffset;
54 }
55
56 public double getZOffset()
57 {
58 return zOffset;
59 }
60 }
61