简体   繁体   English

加速度计与重力传感器

[英]Accelerometer vs Gravity sensor

Does gravity sensor return right values if device is in motion? 如果设备运动,重力传感器会返回正确的值吗? I thought that gravity sensor use accelerometer to recognize gravitation direction. 我认为重力传感器使用加速度计来识别引力方向。 Are these two sensors different piece of hardware? 这两个传感器是不同的硬件吗?

Albert Einstein answered this question in 1911 阿尔伯特爱因斯坦在1911年回答了这个问题

A little reflection will show that the law of the equality of the inertial and gravitational mass is equivalent to the assertion that the acceleration imparted to a body by a gravitational field is independent of the nature of the body. 稍微反思将表明,惯性和引力质量相等的定律等于通过引力场赋予身体的加速度与身体的性质无关的断言。 For Newton's equation of motion in a gravitational field, written out in full, it is: 对于牛顿在引力场中的运动方程,完整地写出来,它是:

(Inertial mass) \\cdot (Acceleration) = (Intensity of the gravitational field) \\cdot (Gravitational mass). (惯性质量)\\ cdot(加速度)=(重力场的强度)\\ cdot(引力质量)。 It is only when there is numerical equality between the inertial and gravitational mass that the acceleration is independent of the nature of the body. 只有当惯性质量和引力质量之间存在数值相等时,加速度才与身体的性质无关。

— Albert Einstein - 艾尔伯特爱因斯坦

We cannot differentiate the measurement of acceleration from the measurement of gravity since they are equivalent to the observer. 我们无法将加速度的测量与重力测量区分开来,因为它们与观察者相当。 Even if the Android had two sensors they would both be measuring the same thing. 即使Android有两个传感器,它们也会测量相同的东西。

The Gravity sensor is what Android calls a 'software sensor' and calculates its values using more than one hardware sensor. 重力传感器就是Android所谓的“软件传感器”,并使用多个硬件传感器计算其值。

The software Gravity sensor is only available if the device has a gyroscope. 软件重力传感器仅在设备具有陀螺仪时可用。 By combining accelerometer data with gyroscope data, the acceleration due to moving the device can be filtered out to leave the pure gravity signal. 通过将加速度计数据与陀螺仪数据相结合,可以滤除由于移动设备而产生的加速度以留下纯重力信号。 So yes, it will return the right value under motion. 所以是的,它将在运动中返回正确的值。

Thus, the Gravity sensor gives a much better signal for device orientation than just the accelerometer on its own. 因此,重力传感器为设备方向提供了比仅靠加速度计更好的信号。

Combining sensor values is called sensor fusion and important for high quality measurement values. 组合传感器值称为传感器融合 ,对于高质量测量值非常重要。

The Android Documentation describes the Gravity Sensor . Android文档描述了重力传感器

Unfortunately, many Android devices lack a Gyroscope, and thus, will have no Gravity sensor either. 不幸的是,许多Android设备缺少陀螺仪,因此也没有重力传感器。 This leaves you with a sub optimal signal from just the accelerometer alone, giving a lower quality user experience compared to Android devices with both sensors, and lower quality experience compared to iOS devices. 这样,仅使用加速度计就可以获得次优信号,与具有两种传感器的Android设备相比,提供较低质量的用户体验,与iOS设备相比,质量体验较低。

You can block installations on incompatible devices by using a Google Play requirement specification as follows: 您可以使用Google Play要求规范阻止不兼容设备上的安装,如下所示:

<uses-feature android:name="android.hardware.sensor.gyroscope" />

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

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