Android 中的“重力”和“加速度”传感器有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10446610/
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
What is the difference between "gravity" and "acceleration" sensors in Android?
提问by Suzan Cioc
What is the difference between gravity and acceleration sensors in Android? From my point of view the physical value is the same in both cases.
Android 中的重力和加速度传感器有什么区别?从我的角度来看,两种情况下的物理价值是相同的。
Which one measures the force acting on unit mass inside the device?
哪一个测量作用在设备内部单位质量上的力?
ADDITION
添加
The question is: what physical quantity is measured by these sensors? According to equivalence principlethe acceleration and gravity are indistinguishable and the only way to measure both is by usual (but 3d) spring balance.
问题是:这些传感器测量的是什么物理量?根据等效原理,加速度和重力是无法区分的,测量两者的唯一方法是通过通常的(但 3d)弹簧天平。
回答by lenik
Acceleration sensor gives you back the sum of all forces applied to your device, while Gravity sensor returns only the influence of gravity. If you want to exclude the gravity from acceleration, you may use a high-pass filter or just subtract the gravity sensor values from acceleration sensor values -- not sure which method gives better precision.
加速度传感器为您返回施加到设备上的所有力的总和,而重力传感器仅返回重力的影响。如果您想从加速度中排除重力,您可以使用高通滤波器或仅从加速度传感器值中减去重力传感器值——不确定哪种方法能提供更好的精度。
Another method could be using Sensor.TYPE_LINEAR_ACCELERATION, which gives exactly (acceleration - gravity), however you should check if it's available on the device. I've found a few devices, which have ACCELERATION sensor working, but no response from GRAVITY or LINEAR_ACCELERATION sensors.
另一种方法可能是使用 Sensor.TYPE_LINEAR_ACCELERATION,它准确地给出(加速度 - 重力),但是您应该检查它是否在设备上可用。我发现了一些设备,它们的 ACCELERATION 传感器工作,但 GRAVITY 或 LINEAR_ACCELERATION 传感器没有响应。
回答by cesarsalgado
This link might be helpful: http://www.sensorplatforms.com/which-sensors-in-android-gets-direct-input-what-are-virtual-sensors
此链接可能会有所帮助:http: //www.sensorplatforms.com/which-sensors-in-android-gets-direct-input-what-are-virtual-sensors
The following excerpt summarize the answer for your question:
以下摘录总结了您的问题的答案:
"The list... includes both physical sensors and sensor types with values derived from physical sensors, sometimes these are called virtual sensors... The virtual sensors types (gravity, linear acceleration, and rotation vector) provide values derived by combining the results from physical sensors intelligently... The rotation vector is a combination of the accelerometer, the magnetometer, and sometimes the gyroscope to determine the three-dimensional angle along which the Android device lays with respect to the Earth frame coordinates. By knowing the rotation vector of a device, accelerometer data can be separated into gravity and linear acceleration."
“列表......包括物理传感器和传感器类型,其值来自物理传感器,有时这些被称为虚拟传感器......虚拟传感器类型(重力、线性加速度和旋转矢量)提供通过组合结果得出的值从物理传感器智能...旋转矢量是加速度计,磁力计,有时陀螺仪的组合来确定Android设备相对于地球坐标系的三维角度。通过知道旋转矢量对于设备,加速度计数据可以分为重力和线性加速度。”
This link https://stackoverflow.com/a/8238389/604964also says that the gravity values are computed using a Butterworth filter.
此链接https://stackoverflow.com/a/8238389/604964还说重力值是使用巴特沃斯滤波器计算的。