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