本文介绍了通过组合TYPE_ACCELEROMETER和TYPE_MAGNETIC_FIELD,Sensor.TYPE_ROTATION_VECTOR和getOrientation之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个根据手机的实际位置操纵遥控车的应用程序.

I'm developing an application which steers a RC Car according to the actual position of a mobile phone.

由于TYPE_ORIENTATION已被Android弃用(有人知道为什么它会被弃用吗?)我正在使用(Magnetic_Field和Accelerometer)的RotationMatrix来获取目前可以正常使用的手机方向.

Because TYPE_ORIENTATION is deprecated by Android (does someone know why exactly is it deprecated?) I'm using the RotationMatrix of (Magnetic_Field and Accelerometer) to get the orientation of the phone which works fine at the moment.

但是在我的研究过程中,我遇到了Sensor.TYPE_ROTATION_VECTOR以获取方向信息.这样做有好处吗?还是建议使用哪种方法?

But during my research I come across with Sensor.TYPE_ROTATION_VECTOR for getting the orienation. Does this have some benefits or what methode is recommended to use?

谢谢

推荐答案

TYPE_ROTATION_VECTOR通过OS级软件将多个传感器融合在一起.这是一个很好的教程,解释了这些区别以及代码示例和作者的发现: https://www.journal.deviantdev.com/android-compass-azimuth-calculating/

TYPE_ROTATION_VECTOR fuses multiple sensors together via OS level software. Here's a good tutorial explaining the differences, along with code samples and the author's findings: https://www.journal.deviantdev.com/android-compass-azimuth-calculating/

我注意到,在Nexus 5X上,方位(罗盘方向)有时会变得不准确.但是,如果我去其他地方,例如Google Maps,它还会显示错误的指南针方向.因此,这似乎是设备问题,传感器问题或两者都有.

I have noticed that on my Nexus 5X, the azimuth (compass direction), becomes inaccurate from time-to-time. However, if I go to something else, like Google Maps, it also shows the incorrect compass direction. So this seems like either an issue with the device, its sensors or both.

TYPE_ROTATION_VECTOR确实对值进行了一些平滑处理,然后,如果您想进行其他平滑处理,则可以仅添加一个低通滤波器.祝你好运!

TYPE_ROTATION_VECTOR does provide some nice smoothing of the values, and then you can just add a low-pass filter if you want additional smoothing. Good luck!

这篇关于通过组合TYPE_ACCELEROMETER和TYPE_MAGNETIC_FIELD,Sensor.TYPE_ROTATION_VECTOR和getOrientation之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-15 13:24