Android中的SensorManager.getRotationMatrix重力参数或加速度计参数值?
在 Android Documentation 指定了第三个参数,然后
float[] gravity
指定了
[0 0 g] = R * gravity (g = magnitude of gravity)
现在,在大多数示例中在网上我可以看到每个人都将加速度计值发送到 getRotationMatrix,但是,难道我不应该只发送重力值吗?
例如,如果手机有重力传感器, 我应该将其原始输出发送到 getRotationMatrix 吗? 如果没有,我应该发送加速度计值吗?我应该先提取非重力分量吗? (因为加速度计值是加速度减去 G)。
在具有该传感器的手机中,使用重力传感器值会比使用加速度计值更可靠吗?
提前致谢!吉列尔莫.
In Android Documentation is specified the third parameter as
float[] gravity
then is specifies
[0 0 g] = R * gravity (g = magnitude of gravity)
Now, in most of the examples online I can see everyone sending accelerometer values to getRotationMatrix, but, Isn't suppose that I should send only gravity values?
For example, if the mobile phone has the gravity sensor,
Should I send it raw output to getRotationMatrix?
If it hasn't one, Should I send accelerometer values? Should I extract non gravity components first? (as accelerometer values are Acceleration minus G).
Will the use of gravity sensor values be more reliable than using accelerometer values in mobile phones that have that sensor?
Thanks in advance! Guillermo.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您只看到使用加速度计值的示例的原因是因为重力传感器仅在 API 9 中启动,而且大多数手机可能不会将此值与加速度计值分开,或者没有传感器等。
另一个原因是因为在大多数情况下结果往往是相同的,因为加速度传感器输出的是设备线性加速度加上重力,但大多数时候手机会静止不动甚至匀速移动,因此设备加速度将为零。
来自
setRotationMatrix
Android 文档:现在,您问重力数据是否更可靠?好吧,没有什么比测试更好的了,但我想这不会有太大区别,这实际上取决于您想要哪个应用程序。此外,获取简单的重力值并不简单,它需要过滤,因此最终可能会得到嘈杂的结果。
I think the reason you only see examples using the accelerometer values is because the gravity sensor was only launched in API 9 and also because most phones might not give this values separated from the accelerometer values, or dont have the sensor, etc, etc..
Another reason would be because in most of the cases the result tend to be the same, since what the accelerometer sensor outputs is the device linear acceleration plus gravity, but most of the time the phone will be standing still or even moving at a constant velocity, thus the device acceleration will be zero.
From the
setRotationMatrix
Android Docs:Now, you're asking if the gravity data would me more reliable? Well, there is nothing like testing, but I suppose it wouldn't make much difference and it really depends on which application you want. Also, obtaining the simple gravity values is not trivial and it requires filtering, so you could end up with noisy results.