简体   繁体   English

如何估计两个Android设备之间的距离? (蓝牙优先)

[英]How to estimate distance between two android devices? (bluetooth preferred)

Target is not to have the real distance.目标是没有真正的距离。 It is something simpler.这是更简单的事情。
Target is to check whether another device is very very close .目标是检查另一个设备是否非常非常接近 True or false.对或错。 Let's say 10 or 15 cms is close so our check is true and any device further away fails the check and it is false.假设 10 或 15 厘米很近,所以我们的检查是正确的,任何更远的设备都无法通过检查,这是错误的。

My first approach was to use api's method fetchUuidsWithSdp() but it failed!我的第一种方法是使用 api 的方法fetchUuidsWithSdp()但它失败了!
Latency seemed the same whether the devices where a couple of cms away or at the other end of a large room!无论是距离几厘米的设备还是在大房间的另一端,延迟似乎都是一样的!

Any solution even without bluetooth is acceptable.即使没有蓝牙,任何解决方案都是可以接受的。 For instance, I am totally unfamiliar with the wifi direct p2p protocol.例如,我完全不熟悉wifi direct p2p协议。 Maybe there could be something in there useful to have a rough estimation of distance.也许那里可能有一些有用的东西来粗略估计距离。

Edit: I am reading about Received Signal Strength Indicator( RSSI ).编辑:我正在阅读有关接收信号强度指示器( RSSI )的信息。 This could be used for our particular case, a rough estimation of distance between devices.这可以用于我们的特殊情况,粗略估计设备之间的距离。 But maybe there could be something to combine in order to improve the accuracy.但也许可以结合一些东西来提高准确性。

Edit: I put Ralgha's answer to the test.编辑:我将 Ralgha 的答案用于测试。 I did established a connection and had a minor protocol to ping-pong among devices.我确实建立了一个连接,并有一个在设备之间进行乒乓的小协议。
When ping-ponged with 1 byte average latency was 22.6000 msec when very close and 22.6087 msec when on the other corner of the room.当以1 字节进行乒乓时,非常接近时平均延迟为 22.6000 毫秒,而在房间的另一个角落时为 22.6087 毫秒。
When ping-ponged with 1024 bytes average latency was 40.3173 msec when very close and even smaller, 32.3138 msec, when on the other corner of the room.当以1024 字节进行乒乓时,距离非常近时平均延迟为 40.3173 毫秒,而在房间的另一个角落时则更小,为 32.3138 毫秒。
After all, indeed, latency does not carry any information about distance !毕竟,延迟确实不携带任何有关距离的信息

Thanks!谢谢!

你可以用声音测量距离

I've looked into bluetooth positioning and it istn' quite as easy as detecting the signal strength.我研究了蓝牙定位,它和检测信号强度一样简单。 For really accurate results you also need to take into account the types of phone your using, the battery type and the condition of the battery.为了获得真正准确的结果,您还需要考虑您使用的手机类型、电池类型和电池状况。 You also have to take into account the environment and how it might efffect the signal strength, and also obstacles that may interfere with the signal, such as people, walls, tables, etc.您还必须考虑环境及其对信号强度的影响,以及可能干扰信号的障碍物,例如人、墙壁、桌子等。

To determine the distance you would also need to use triangulation techniques to determine the position of a mobile.要确定距离,您还需要使用三角测量技术来确定移动设备的位置。 You can also set up a number transmitters in your environment and measure against each one.您还可以在您的环境中设置多个发射器并针对每个发射器进行测量。 Knowing the positions of these transmitters you can then work out the position of the phone.了解这些发射器的位置后,您就可以计算出手机的位置。

However, the signal strengths will vary and you will have to do a lot of calibration.但是,信号强度会有所不同,您必须进行大量校准。 There a number of scientific papers that give some insight into the algorythms required.有许多科学论文可以深入了解所需的算法。 There are also a couple of companies that provide this as a service, used in malls, museums etc.还有几家公司提供这种服务,用于商场、博物馆等。

That said, if you can get the signal strength then you should be able to work out a basic near or far result, it just won't be fully accurate, and in this case i still think having a number of transmitters would still help a lot.也就是说,如果您可以获得信号强度,那么您应该能够计算出基本的远近结果,它不会完全准确,在这种情况下,我仍然认为拥有多个发射器仍然有助于很多。

Paper, some of the pitfalls PDF(download), another paper 论文,一些陷阱PDF(下载),另一篇论文

THere are loads of papers i've read from googling bluetooth positioning that will give you some pointers.我从谷歌搜索蓝牙定位中读到了很多论文,它们会给你一些指导。

The only feasible way to do it that I can think of is with NFC.我能想到的唯一可行的方法是使用 NFC。 To use Bluetooth or Wi-Fi you'd have to do it via signal strength, but every transmitter is different so that wouldn't be reliable at all.要使用蓝牙或 Wi-Fi,您必须通过信号强度来实现,但每个发射器都不同,因此根本不可靠。

Latency is rather useless since the radio waves travel at the speed of light and the time difference between traveling an inch and a mile is essentially zero.延迟是相当无用的,因为无线电波以光速传播,而传播一英寸和一英里之间的时间差基本上为零。 To measure that difference you'd need a much higher resolution than you have in a phone.要测量这种差异,您需要比手机更高的分辨率。

You are not specifying the objective for this distance detection, but if you could add some additional requirements to that (ie phone orientation and flash light), a totally different approach could probably be used.您没有指定此距离检测的目标,但如果您可以为此添加一些额外要求(即手机方向和闪光灯),则可能会使用完全不同的方法。

If both devices are oriented in a way that both cameras face each other, the flash light could be used to validate the correct phone and distance.如果两个设备都以两个摄像头面对面的方式定向,则可以使用闪光灯来验证正确的手机和距离。 The size of the white spot generated in the camera image decreases rapidly with distance, and a specific flash sequency could differentiate between the other phone flash light and other light sources.相机图像中产生的白点的大小随着距离的增加而迅速减小,特定的闪光序列可以区分其他手机闪光灯和其他光源。

This could require some tweaking to work outdoors, as for the same distance the spot size will be much smaller ...这可能需要一些调整才能在户外工作,因为对于相同的距离,光斑尺寸会小得多......

Regards.问候。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM