calculate accurate Ibeacon distance

时间:2017-08-04 12:45:28

标签: ios swift core-location ibeacon

I'm at the beginning of developing an indoor navigation system with the help of Beacons in ios. We have 3 Bluecast beacons now and I am not getting accurate distance from these three. I have tested by putting three beacons in a same position but it's showing different distance and rssi values in major time.

I tried same with beacon provider reveal app and my own app but both apps are showing same value.

example code is

 locationManager = CLLocationManager()
 locationManager.delegate = self

 let uuid = UUID(uuidString: uuidStr)
 beaconRegion = CLBeaconRegion(proximityUUID: uuid!, identifier: "Beacones")

 beaconRegion.notifyOnEntry = true
 beaconRegion.notifyOnExit = true
 locationManager.requestAlwaysAuthorization()
 locationManager.startMonitoring(for: beaconRegion)
 locationManager.startUpdatingLocation()

distance calculator logic is in below

 public func calculateAccuracy(txPower : Double, rssi : Double) -> Double {
        if (rssi == 0) {
            return -1.0; // if we cannot determine accuracy, return -1.
        }

        let ratio :Double = rssi*1.0/txPower;
        if (ratio < 1.0) {
            return pow(ratio,10.0);
        }
        else {
            let accuracy :Double =  (0.89976)*pow(ratio,7.7095) + 0.111;
            return accuracy;
        }
    }

1 个答案:

答案 0 :(得分:1)

小心不要在准确度方面设定不切实际的期望。估计与蓝牙信号电平的距离最多可以粗略估计距离,但是有很多陷阱可能会使它无法正常工作。

为获得最佳效果:

  • 将信标发射机设置为尽可能高的值,以提高信噪比,使rssi更加一致。

  • 将信标广告费率设置为尽可能高,以获得尽可能多的统计样本,以平均噪音。

  • 将txPower常数调整为特定设备接收器上一米处的测量平均RSSI,用于距离估算。

  • 如果您发现公式的估计值一致或过低,请根据需要调整常数以获得最佳拟合。

意识到障碍物(甚至是人体),反射,无线电噪音,手机外壳,甚至不同的手机型号都会影响结果。估计2-3米的距离效果最佳。在距离较远的情况下,当信号电平随距离呈指数下降时,您会看到更高的错误率。