xcode 如何使用蓝牙测量两个iphone设备之间的距离?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3624945/
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-09-09 03:32:39  来源:igfitidea点击:

How to measure distance between two iphone devices using bluetooth?

iphonecocoa-touchxcodebluetooth

提问by Floppy Max

I'd like to do something in the following using bluetooth.

我想在以下使用蓝牙做一些事情。

  1. Measure and display how far my iPhone is from another iPhone.
  2. Display direction of my iPhone.
  1. 测量并显示我的 iPhone 与另一部 iPhone 的距离。
  2. 我的 iPhone 的显示方向。

For example,

例如,

I'd like to display something in the following on my iPhone application.

我想在我的 iPhone 应用程序上显示以下内容。

My iPhone is connected to another iPhone:Harry's iPhone.

我的 iPhone 已连接到另一部 iPhone:Harry 的 iPhone。

In this case,

在这种情况下,

  • Distance : 3m 45.3cm (Accuracy:milimeter)
  • Direction : North East(one of 8 available directions)
  • 距离:3m 45.3cm(精度:毫米)
  • 方向:东北(8 个可用方向之一)

Does anyone know how to do this?

有谁知道如何做到这一点?

回答by Giuseppe Cardone

Using bluetooth for localization is a very well known research field (ref.). The short answer is: you can't. Signal strength isn't a good indicator of distance between two connected bluetooth devices, because it is too much subject to environment condition (is there a person between the devices? How is the owner holding his/her device? Is there a wall? Are there any RF reflecting surfaces?). Using bluetooth you can at best obtain a distance resolution of few meters, but you can't calculate the direction, not even roughly.

使用蓝牙进行定位是一个众所周知的研究领域(参考文献)。简短的回答是:你不能。信号强度不能很好地指示两个连接的蓝牙设备之间的距离,因为它受环境条件的影响太大(设备之间是否有人?所有者如何拿着他/她的设备?是否有墙?是否存在?)有任何射频反射面吗?)。使用蓝牙您最多可以获得几米的距离分辨率,但您无法计算方向,甚至无法粗略计算。

You may obtain better results by using multiple bluetooth devices and triangulating the various signal strength, but even in this case it's hard to be more accurate than few meters in your estimates.

您可以通过使用多个蓝牙设备并对各种信号强度进行三角测量来获得更好的结果,但即使在这种情况下,您的估计也很难比几米更准确。

回答by Christopher Edwards

You could use sound and knowledge of speed sound to calculate the distance between the iphones.

您可以使用声音和速度声音知识来计算 iPhone 之间的距离。

回答by CW0007007

In iOS7 Apple introduced iBeacons. This will give you the distance between 1 phone and another. It is simple to setup, check out the WWDC sample AirLocate.

在 iOS7 中,Apple 引入了 iBeacons。这将为您提供一部手机与另一部手机之间的距离。设置很简单,请查看 WWDC 示例 AirLocate。

回答by heb

You can't do this with bluetooth. You could meassure the distance between two BT devices by analysing the BT reception quality - but this will strongly differ in every new environment (e.g. simply a new room or in the open air). For direction: here is exactly the same problem, especially inside buildings. A lot of BT signal echos will make it almost impossible to receive useful direction data. There are ways to determine distance and directions via wireless connections (doesn't matter if BT, WLAN or ZigBee or something else) - not with standard customer devices, but with real-hitech laboratory equipment.

你不能用蓝牙做到这一点。您可以通过分析 BT 接收质量来测量两个 BT 设备之间的距离 - 但在每个新环境中(例如只是一个新房间或露天),这将有很大不同。对于方向:这是完全相同的问题,尤其是在建筑物内部。大量的 BT 信号回波将使接收有用的方向数据几乎不可能。有多种方法可以通过无线连接(无论是 BT、WLAN 或 ZigBee 还是其他东西)来确定距离和方向——不是使用标准的客户设备,而是使用真正的高科技实验室设备。

回答by Simon Hughes

For direction, you would have to hold the phone away from you and spin in a circle allowing the phone to measure the increase/decrease in signal strength. Not sure how good the iPhone signal reception will be.

对于方向,您必须将手机远离您并旋转一圈,以便手机测量信号强度的增加/减少。不确定 iPhone 的信号接收效果如何。

You could estimate the distance by looking at the signal receive strength. You will have to perform many tests, in different environments in order to get some half decent metrics to use within your app.

您可以通过查看信号接收强度来估计距离。您将不得不在不同的环境中执行许多测试,以便在您的应用程序中使用一些不错的指标。

回答by Ching Liu

You can't do it against only one Bluetooth device, but you might with 2. Assuming the 2 remote devices are in static location (speakers), and you move your mobile (pun intended) Bluetooth device. You should be able to derive your angle based on speed of distance change from the 2 devices. Only problem is that the solution has 2 values, but that might be doable if you know which side of the plane you're on.

您不能只针对一个蓝牙设备执行此操作,但可以使用 2 个。假设 2 个远程设备处于静态位置(扬声器),并且您移动了您的移动(双关语)蓝牙设备。您应该能够根据 2 个设备的距离变化速度推导出您的角度。唯一的问题是该解决方案有 2 个值,但如果您知道您在飞机的哪一侧,这可能是可行的。

回答by A Abdullah

As what Giuseppe Cardone has mentioned, using the signal strength wont work. However, I would suggest requesting the location information of the other device (let's say that, you install an app on the other device that replies to location requests.). Once you get the location information from the other device you may compare it with your device's location and calculate the distance and the direction.

正如 Giuseppe Cardone 所提到的,使用信号强度是行不通的。但是,我建议请求另一台设备的位置信息(假设您在另一台设备上安装了一个响应位置请求的应用程序。)。从其他设备获取位置信息后,您可以将其与设备的位置进行比较并计算距离和方向。