ios 了解信标距离

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20416218/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 22:38:29  来源:igfitidea点击:

Understanding ibeacon distancing

iosobjective-cbluetoothbluetooth-lowenergyibeacon

提问by rambossa

Trying to grasp a basic concept of how distancing with ibeacon (beacon/ Bluetooth-lowenergy/BLE) can work. Is there any true documentation on how far exactly an ibeacon can measure. Lets say I am 300 feet away...is it possible for an ibeacon to detect this?

试图掌握与 ibeacon(信标/蓝牙低功耗/BLE)保持距离如何工作的基本概念。是否有任何关于 ibeacon 可以测量多远的真实文档。假设我在 300 英尺外……信标有可能检测到这一点吗?

Specifically for v4 &. v5 and with iOS but generally any BLE device.

专门用于 v4 &。v5 和 iOS,但通常是任何 BLE 设备。

How does Bluetooth frequency & throughput affect this? Can beacon devices enhance or restrict the distance / improve upon underlying BLE?

蓝牙频率和吞吐量对此有何影响?信标设备可以增强或限制距离/改善底层 BLE 吗?

ie

IE

               | Range       | Freq       | T/sec      | Topo       |      
               |–—–––––––––––|–—––––––––––|–—––––––––––|–—––––––––––|
Bluetooth v2.1 | Up to 100 m | < 2.481ghz | < 2.1mbit  | scatternet |
               |-------------|------------|------------|------------|
Bluetooth v4   |     ?       | < 2.481ghz | < 305kbit  | mesh       |
               |-------------|------------|------------|------------|
Bluetooth v5   |     ?       | < 2.481ghz | < 1306kbit | mesh       |

回答by davidgyoung

The distance estimate provided by iOS is based on the ratio of the beacon signal strength (rssi) over the calibrated transmitter power (txPower). The txPower is the known measured signal strength in rssi at 1 meter away. Each beacon must be calibrated with this txPower value to allow accurate distance estimates.

iOS 提供的距离估计基于信标信号强度 (rssi) 与校准发射器功率 (txPower) 的比率。txPower 是 1 米外以 rssi 为单位的已知测量信号强度。每个信标都必须使用此 txPower 值进行校准,以允许准确的距离估计。

While the distance estimates are useful, they are not perfect, and require that you control for other variables. Be sure you read up on the complexities and limitationsbefore misusing this.

虽然距离估计很有用,但它们并不完美,需要您控制其他变量。 在滥用它之前,请务必阅读复杂性和局限性

When we were building the Android iBeacon library, we had to come up with our own independent algorithm because the iOS CoreLocation source code is not available. We measured a bunch of rssi measurements at known distances, then did a best fit curve to match our data points. The algorithm we came up with is shown below as Java code.

当我们在构建 Android iBeacon 库时,因为没有 iOS CoreLocation 源代码,我们不得不想出我们自己的独立算法。我们在已知距离处测量了一堆 RSSI 测量值,然后做了一个最佳拟合曲线来匹配我们的数据点。我们提出的算法如下所示为 Java 代码。

Note that the term "accuracy" here is iOS speak for distance in meters. This formula isn't perfect, but it roughly approximates what iOS does.

请注意,此处的“准确度”一词是 iOS 中以米为单位的距离。这个公式并不完美,但它大致近似于 iOS 的功能。

protected static double calculateAccuracy(int txPower, double rssi) {
  if (rssi == 0) {
    return -1.0; // if we cannot determine accuracy, return -1.
  }

  double ratio = rssi*1.0/txPower;
  if (ratio < 1.0) {
    return Math.pow(ratio,10);
  }
  else {
    double accuracy =  (0.89976)*Math.pow(ratio,7.7095) + 0.111;    
    return accuracy;
  }
}   

Note:The values 0.89976, 7.7095 and 0.111 are the three constants calculated when solving for a best fit curve to ourmeasured data points. YMMV

注:该值0.89976,7.7095和0.111是三个常量求解最佳拟合曲线来计算时,我们测得的数据点。青年会

回答by Andrzej D?browski

I'm very thoroughly investigating the matter of accuracy/rssi/proximity with iBeacons and I really really think that all the resources in the Internet (blogs, posts in StackOverflow) get it wrong.

我非常彻底地调查了 iBeacons 的准确性/rssi/接近性问题,我真的认为互联网上的所有资源(博客、StackOverflow 中的帖子)都弄错了。

davidgyoung (accepted answer, > 100 upvotes) says:

davidgyoung(接受的答案,> 100 个赞成票)说:

Note that the term "accuracy" here is iOS speak for distance in meters.

请注意,此处的“准确度”一词是 iOS 中以米为单位的距离。

Actually, most people say this but I have no idea why! Documentation makes it very very clear that CLBeacon.proximity:

事实上,大多数人都这么说,但我不知道为什么!文档非常清楚地表明 CLBeacon.proximity:

Indicates the one sigma horizontal accuracy in meters.Use this property to differentiate between beacons with the same proximity value. Do not use it to identify a precise location for the beacon. Accuracy values may fluctuate due to RF interference.

表示以米为单位的 1 西格玛水平精度。使用此属性来区分具有相同接近度值的信标。不要用它来确定信标的精确位置。由于射频干扰,精度值可能会波动。

Let me repeat: one sigma accuracy in meters. All 10 top pages in google on the subject has term "one sigma" only in quotation from docs, but none of them analyses the term, which is core to understand this.

让我再说一遍:以米为单位的 sigma 精度。谷歌关于该主题的所有 10 个热门页面都有术语“one sigma”,仅引用自文档,但没有人分析该术语,这是理解这一点的核心。

Very important is to explain what is actually one sigma accuracy. Following URLs to start with: http://en.wikipedia.org/wiki/Standard_error, http://en.wikipedia.org/wiki/Uncertainty

非常重要的是解释什么实际上是1 sigma 准确度。以下 URL 开头:http://en.wikipedia.org/wiki/Standard_error, http://en.wikipedia.org/wiki/Uncertainty

In physical world, when you make some measurement, you always get different results (because of noise, distortion, etc) and very often results form Gaussian distribution. There are two main parameters describing Gaussian curve:

在物理世界中,当您进行一些测量时,您总是会得到不同的结果(由于噪声、失真等),并且结果通常形成高斯分布。描述高斯曲线的主要参数有两个:

  1. mean (which is easy to understand, it's value for which peak of the curve occurs).
  2. standard deviation, which says how wide or narrow the curve is. The narrower curve, the better accuracy, because all results are close to each other. If curve is wide and not steep, then it means that measurements of the same phenomenon differ very much from each other, so measurement has a bad quality.
  1. 平均值(这很容易理解,它是曲线峰值出现的值)。
  2. 标准偏差,表示曲线有多宽或多窄。曲线越窄,精度越高,因为所有结果都彼此接近。如果曲线宽而不陡,则说明同一现象的测量结果相差很大,测量质量差。

one sigmais another way to describe how narrow/wide is gaussian curve.
It simply says that if mean of measurement is X, and one sigmais σ, then 68% of all measurements will be between X - σand X + σ.

one sigma是另一种描述高斯曲线窄/宽的方法。
它只是说,如果测量的平均值是 X,一个 sigma是 σ,那么所有测量的 68% 将在X - σ和之间X + σ

Example. We measure distance and get a gaussian distribution as a result. The mean is 10m. If σ is 4m, then it means that 68% of measurements were between 6m and 14m.

例子。我们测量距离并得到高斯分布作为结果。平均值为 10m。如果 σ 为 4m,则意味着 68% 的测量值在 6m 和 14m 之间。

When we measure distance with beacons, we get RSSI and 1-meter calibration value, which allow us to measure distance in meters. But every measurement gives different values, which form gaussian curve. And one sigma(and accuracy) is accuracy of the measurement, not distance!

当我们使用信标测量距离时,我们会得到 RSSI 和 1 米校准值,这使我们能够以米为单位测量距离。但是每次测量都会给出不同的值,形成高斯曲线。和一个西格马(和精确度)是测量,没有距离的准确性!

It may be misleading, because when we move beacon further away, one sigmaactually increases because signal is worse. But with different beacon power-levels we can get totally different accuracy values without actually changing distance. The higher power, the less error.

这可能会产生误导,因为当我们将信标移得更远时,由于信号更差,一个 sigma实际上会增加。但是使用不同的信标功率级别,我们可以获得完全不同的精度值,而无需实际改变距离。功率越高,误差越小。

There is a blog post which thoroughly analyses the matter: http://blog.shinetech.com/2014/02/17/the-beacon-experiments-low-energy-bluetooth-devices-in-action/

有一篇博客文章彻底分析了这个问题:http: //blog.shinetech.com/2014/02/17/the-beacon-experiments-low-energy-bluetooth-devices-in-action/

Author has a hypothesis that accuracy is actually distance. He claims that beacons from Kontakt.io are faulty beacuse when he increased power to the max value, accuracy value was very small for 1, 5 and even 15 meters. Before increasing power, accuracy was quite close to the distance values. I personally think that it's correct, because the higher power level, the less impact of interference. And it's strange why Estimote beacons don't behave this way.

作者有一个假设,即准确度实际上是距离。他声称 Kontakt.io 的信标是有问题的,因为当他将功率增加到最大值时,1、5 甚至 15 米的精度值非常小。在增加功率之前,精度非常接近距离值。我个人认为是正确的,因为功率电平越高,干扰的影响越小。奇怪的是,为什么 Estimote 信标不会以这种方式运行。

I'm not saying I'm 100% right, but apart from being iOS developer I have degree in wireless electronics and I think that we shouldn't ignore "one sigma" term from docs and I would like to start discussion about it.

我并不是说我 100% 正确,但除了作为 iOS 开发人员之外,我还拥有无线电子学学位,我认为我们不应该忽略文档中的“one sigma”术语,我想开始讨论它。

It may be possible that Apple's algorithm for accuracy just collects recent measurements and analyses the gaussian distribution of them. And that's how it sets accuracy. I wouldn't exclude possibility that they use info form accelerometer to detect whether user is moving (and how fast) in order to reset the previous distribution distance values because they have certainly changed.

Apple 的准确性算法可能只是收集最近的测量值并分析它们的高斯分布。这就是它设置准确性的方式。我不排除他们使用信息形式的加速度计来检测用户是否移动(以及移动的速度)以重置以前的分布距离值的可能性,因为它们肯定已经改变了。

回答by Mark Fassler

The iBeacon output power is measured (calibrated) at a distance of 1 meter. Let's suppose that this is -59 dBm (just an example). The iBeacon will include this number as part of its LE advertisment.

iBeacon 输出功率是在 1 米距离处测量(校准)的。让我们假设这是 -59 dBm(只是一个例子)。iBeacon 将把这个数字作为其 LE 广告的一部分。

The listening device (iPhone, etc), will measure the RSSI of the device. Let's suppose, for example, that this is, say, -72 dBm.

监听设备(iPhone 等)将测量设备的 RSSI。例如,让我们假设这是-72 dBm。

Since these numbers are in dBm, the ratio of the power is actually the difference in dB. So:

由于这些数字以 dBm 为单位,因此功率比实际上是以 dB 为单位的差值。所以:

ratio_dB = txCalibratedPower - RSSI

To convert that into a linear ratio, we use the standard formula for dB:

要将其转换为线性比率,我们使用 dB 的标准公式:

ratio_linear = 10 ^ (ratio_dB / 10)

If we assume conservation of energy, then the signal strength must fall off as 1/r^2. So:

如果我们假设能量守恒,那么信号强度必须下降为 1/r^2。所以:

power = power_at_1_meter / r^2. Solving for r, we get:

power = power_at_1_meter / r^2. 求解 r,我们得到:

r = sqrt(ratio_linear)

In Javascript, the code would look like this:

在 Javascript 中,代码如下所示:

function getRange(txCalibratedPower, rssi) {
    var ratio_db = txCalibratedPower - rssi;
    var ratio_linear = Math.pow(10, ratio_db / 10);

    var r = Math.sqrt(ratio_linear);
    return r;
}

Note, that, if you're inside a steel building, then perhaps there will be internal reflections that make the signal decay slower than 1/r^2. If the signal passes through a human body (water) then the signal will be attenuated. It's very likely that the antenna doesn't have equal gain in all directions. Metal objects in the room may create strange interference patterns. Etc, etc... YMMV.

请注意,如果您在钢结构建筑内,那么可能会有内部反射使信号衰减慢于 1/r^2。如果信号通过人体(水),则信号会衰减。很可能天线在所有方向上的增益不同。房间里的金属物体可能会产生奇怪的干扰图案。等等,等等...... YMMV。

回答by Jiaru

iBeacon uses Bluetooth Low Energy(LE) to keep aware of locations, and the distance/range of Bluetooth LE is 160ft (http://en.wikipedia.org/wiki/Bluetooth_low_energy).

iBeacon 使用低功耗蓝牙(LE)来感知位置,蓝牙 LE 的距离/范围为 160 英尺(http://en.wikipedia.org/wiki/Bluetooth_low_energy)。

回答by Chris Stratton

Distances to the source of iBeacon-formatted advertisement packets are estimatedfrom the signal path attenuation calculated by comparing the measured received signal strength to the claimed transmit power which the transmitter is supposed to encode in the advertising data.

到 iBeacon 格式的广告数据包源的距离是根据信号路径衰减来估计的,该信号路径衰减通过将测量的接收信号强度与发射机应该在广告数据中编码的声称的发射功率进行比较来计算。

A path loss based scheme like this is only approximate and is subject to variation with things like antenna angles, intervening objects, and presumably a noisy RF environment. In comparison, systems really designed for distance measurement (GPS, Radar, etc) rely on precise measurements of propagation time, in same cases even examining the phase of the signal.

像这样的基于路径损耗的方案只是近似的,并且会随着天线角度、干扰物体和可能嘈杂的 RF 环境等因素而变化。相比之下,真正为距离测量设计的系统(GPS、雷达等)依赖于传播时间的精确测量,在相同情况下甚至检查信号的相位。

As Jiaru points out, 160 ft is probably beyond the intended range, but that doesn't necessarily mean that a packet will neverget through, only that one shouldn't expect it to work at that distance.

正如 Jiaru 指出的那样,160 英尺可能超出了预期的范围,但这并不一定意味着数据包永远不会通过,只是人们不应该期望它在那个距离工作。

回答by danh

It's possible, but it depends on the power output of the beacon you're receiving, other rf sources nearby, obstacles and other environmental factors. Best thing to do is try it out in the environment you're interested in.

这是可能的,但这取决于您接收的信标的功率输出、附近的其他射频源、障碍物和其他环境因素。最好的办法是在您感兴趣的环境中尝试一下。

回答by BlueSpectrumz

With multiple phones and beacons at the same location, it's going to be difficult to measure proximity with any high degree of accuracy. Try using the Android "b and l bluetooth le scanner" app, to visualize the signal strengths (distance) variations, for multiple beacons, and you'll quickly discover that complex, adaptive algorithms may be required to provide any form of consistent proximity measurement.

如果在同一位置有多部手机和信标,就很难以任何高精度测量接近度。尝试使用 Android 的“b 和 l 蓝牙文件扫描仪”应用程序来可视化多个信标的信号强度(距离)变化,您会很快发现可能需要复杂的自适应算法来提供任何形式的一致接近度测量.

You're going to see lots of solutions simply instructing the user to "please hold your phone here", to reduce customer frustration.

您将看到许多解决方案只是简单地指示用户“请将您的手机放在此处”,以减少客户的挫败感。