Exemplo n.º 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;
  }
Exemplo n.º 2
0
 public void close() {
   irSensor.close();
 }
Exemplo n.º 3
0
 public IrScanner(Port irSensorPort) {
   irSensor = new EV3IRSensor(irSensorPort);
   SensorMode sensorMode = irSensor.getDistanceMode();
   adaptor = new RangeFinderAdaptor(sensorMode);
 }