예제 #1
0
  private synchronized float getCurrentScanDistance() {
    float currentDistance = getCurrentDistanceFromObject();
    float[] sample = adaptor.getRanges();

    System.out.println("Scan current distance from sensor adaptor: " + currentDistance);
    float[] irSample = new float[irSensor.sampleSize()];

    // get the raw sample data
    irSensor.getDistanceMode().fetchSample(irSample, 0);

    // calculate average of scanned distances
    float scanDistance = findAverageScanDistance(sample);
    return scanDistance;
  }
예제 #2
0
 public void close() {
   irSensor.close();
 }
예제 #3
0
 public IrScanner(Port irSensorPort) {
   irSensor = new EV3IRSensor(irSensorPort);
   SensorMode sensorMode = irSensor.getDistanceMode();
   adaptor = new RangeFinderAdaptor(sensorMode);
 }