“旋转”在Expo-Sensers' devicemotion准确地返回?
我正在构建一个应用程序,我需要在其中依靠指南针/轴承/朝您称呼的内容:北方和手机的Y轴之间的角度。
我阅读了互联网的大部分,并了解了“传感器融合”,它是Android中rotation_vector
的虚拟形式。我熟悉 and
将其归结为Expo-Sensors的DeviceMotion,我的测试代码看起来像是如此:
import { DeviceMotion } from 'expo-sensors'
DeviceMotion.addListener( ({ rotation }) =>
console.info( ( 360 + this.toDegreesInt( rotation.alpha ) ) % 360 )
)
现在,如果我旋转设备,该值以某种方式变化,但是如果我指向北部,我会得到124度的角度,远远超出了该角度未校准的罗盘读数。
另外,如果我旋转设备360度,则假定的方位值永远不会从0到359,而是在某些随机扩散的块中。
在同一设备上的Google导航工作如魅力...
如何使我的指南针起作用?
I'm building an App where I need to rely on compass azimuth/bearing/heading whatever you call it: the angle between the North and the Y-axis of the phone.
I read the greater half of the Internet and learned about "Sensor fusion" and it's virtual form of ROTATION_VECTOR
in Android. I got familiarized with SensorManager and DeviceMotionModule.
Boiling it down to expo-sensors' DeviceMotion, my test code looks like so:
import { DeviceMotion } from 'expo-sensors'
DeviceMotion.addListener( ({ rotation }) =>
console.info( ( 360 + this.toDegreesInt( rotation.alpha ) ) % 360 )
)
Now if I rotate the device, the value changes somehow, but if I point it to the North, I get an angle of 124 degrees which is far beyond the uncalibrated compass reading.
Also, if I rotate the device 360 degrees, the supposed azimuth value never goes from 0 to 359, but rather in some randomly spread chunks.
Google Navigation on the very same device works like charm...
How can I make my compass work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终使用了
Expo-Location
模块喜欢:coords
对象具有带有有效度量的最终数据,并且不需要其他处理。I ended up using the
expo-location
module like so:The
coords
object has final data with valid measures, and no additional processing is required.