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; }
private float getCurrentDistanceFromObject() { return adaptor.getRange(); }