安卓惯性传感器(二)
目錄
- 1.Sensor.TYPE_ACCELEROMETER:
- 原文翻譯
- 筆記
- 2.Sensor.TYPE_GYROSCOPE:
- 原文翻譯
- 筆記
- 3.Sensor.TYPE_GRAVITY:
- 筆記
- 4.Sensor.TYPE_MAGNETIC_FIELD:
- 筆記
- 5.Sensor.TYPE_LIGHT:
- 筆記
- 6.Sensor.TYPE_PROXIMITY:
- 原文翻譯
- 筆記
- 7.Sensor.TYPE_LINEAR_ACCELERATION:
- 筆記
- 8.Sensor.TYPE_ORIENTATION:
- 筆記
- 9.Sensor.TYPE_ROTATION_VECTOR:
- 原文檔翻譯
- 筆記
- 10.Sensor.TYPE_GAME_ROTATION_VECTOR:
- 筆記
- 11.Sensor.TYPE_GYROSCOPE_UNCALIBRATED:
- 筆記
1.Sensor.TYPE_ACCELEROMETER:
原文翻譯
All values are in SI units (m/s^2)
values[0]: Acceleration minus Gx on the x-axis
values[1]: Acceleration minus Gy on the y-axis
values[2]: Acceleration minus Gz on the z-axis
所有值均為SI單位(m/s^2)
值[0]:x軸上的加速度減去Gx
值[1]:加速度減去y軸上的Gy
值[2]:z軸上的加速度減去Gz
A sensor of this type measures the acceleration applied to the device (Ad). Conceptually, it does so by measuring forces applied to the sensor itself (Fs) using the relation:
Ad = - ∑Fs / mass
In particular, the force of gravity is always influencing the measured acceleration:
特別地,重力總是影響著測量到的加速度:
Ad = -g - ∑F / mass
For this reason, when the device is sitting on a table (and obviously not accelerating), the accelerometer reads a magnitude of g = 9.81 m/s^2
因此,當(dāng)設(shè)備坐在桌子上(顯然沒有加速),加速度計讀取g = 9.81 m/s^2的量級
Similarly, when the device is in free-fall and therefore dangerously accelerating towards to ground at 9.81 m/s^2, its accelerometer reads a magnitude of 0 m/s^2.
同樣,當(dāng)設(shè)備處于自由落體狀態(tài),并因此危險地以9.81米/秒2的速度向地面加速時,其加速度計的讀數(shù)為0米/秒2。
It should be apparent that in order to measure the real acceleration of the device, the contribution of the force of gravity must be eliminated. This can be achieved by applying a high-pass filter. Conversely, a low-pass filter can be used to isolate the force of gravity.
顯然,為了測量裝置的實際加速度,必須消除重力的作用。這可以通過應(yīng)用高通濾波器來實現(xiàn)。相反,可以使用低通濾波器來隔離重力。
筆記
- 1.雖然這個文檔在一開始的時候說是隔離重力的,但是可以通過實際測量和后面的描述當(dāng)中知道,這個東西是帶有重力的,需要我們抹除重力的影響。
2.Sensor.TYPE_GYROSCOPE:
原文翻譯
All values are in radians/second and measure the rate of rotation around the device’s local X, Y and Z axis.
所有值都以弧度/秒為單位,測量圍繞設(shè)備本地X、Y和Z軸的旋轉(zhuǎn)速率。
The coordinate system is the same as is used for the acceleration sensor.
坐標(biāo)系與用于加速度傳感器的坐標(biāo)系相同。
Rotation is positive in the counter-clockwise direction. That is, an observer looking from some positive location on the x, y or z axis at a device positioned on the origin would report positive rotation if the device appeared to be rotating counter clockwise.
在逆時針方向上旋轉(zhuǎn)為正。也就是說,一個觀察者從x、y或z軸上的某個正位置觀察一個位于原點的設(shè)備,如果該設(shè)備看起來是逆時針旋轉(zhuǎn),那么該設(shè)備將報告正旋轉(zhuǎn)。
Note that this is the standard mathematical definition of positive rotation and does not agree with the definition of roll given earlier.
注意,這是正旋轉(zhuǎn)的標(biāo)準(zhǔn)數(shù)學(xué)定義,與前面給出的滾動的定義不一致。
values[0]: Angular speed around the x-axis
values[1]: Angular speed around the y-axis
values[2]: Angular speed around the z-axis
筆記
- 1.這里我們注意這個東西的單位是使用弧度/s的,所以這樣才能讀出來那么小的數(shù)值
- 2.這里的正方向是與我們的坐標(biāo)系標(biāo)準(zhǔn)的正方向是一致的。
- 3.這個東西也是加速度坐標(biāo)系。
3.Sensor.TYPE_GRAVITY:
A three dimensional vector indicating the direction and magnitude of gravity. Units are m/s^2. The coordinate system is the same as is used by the acceleration sensor.
Note: When the device is at rest, the output of the gravity sensor should be identical to that of the accelerometer.
注意:當(dāng)設(shè)備處于靜止?fàn)顟B(tài)時,重力傳感器的輸出應(yīng)與加速度計的輸出一致。
筆記
- 1.重力加速和加速度的讀數(shù)一樣可以做一個簡易的靜止判別器。
4.Sensor.TYPE_MAGNETIC_FIELD:
All values are in micro-Tesla (uT) and measure the ambient magnetic field in the X, Y and Z axis.
所有值均以微特斯拉(uT)為單位,測量X、Y、Z軸的環(huán)境磁場。
筆記
就是一個正常的磁場
5.Sensor.TYPE_LIGHT:
values[0]: Ambient light level in SI lux units
筆記
就是一個光強傳感器
6.Sensor.TYPE_PROXIMITY:
原文翻譯
values[0]: Proximity sensor distance measured in centimeters
Note: Some proximity sensors only support a binary near or far measurement. In this case, the sensor should report its maximum range value in the far state and a lesser value in the near state.
values[0]:近距離傳感器距離,單位為厘米
注意:一些接近傳感器只支持二進制近或遠的測量。在這種情況下,傳感器應(yīng)該在遠狀態(tài)報告它的最大量程值,在近狀態(tài)報告一個較小的值。
筆記
- 1.這個東西可以返回一個距離,單位是一個厘米
- 2.但是一些手機上的硬件只能感知遠近,沒有具體的距離,這時候就不能產(chǎn)生具體的返回數(shù)值了,只能是意思的返回一個大數(shù)字或是小數(shù)字。
7.Sensor.TYPE_LINEAR_ACCELERATION:
A three dimensional vector indicating acceleration along each device axis, not including gravity. All values have units of m/s^2.
The coordinate system is the same as is used by the acceleration sensor.
The output of the accelerometer, gravity and linear-acceleration sensors must obey the following relation:
acceleration = gravity + linear-acceleration
- 1.一個三維矢量,表示沿設(shè)備軸方向的加速度,不包括重力。所有值的單位都是m/s^2。
- 2.坐標(biāo)系與加速度傳感器使用的坐標(biāo)系相同。
- 3.加速度計、重力傳感器和直線加速度傳感器的輸出必須遵循以下關(guān)系:加速度=重力+線性加速度
筆記
也就是這個東西是不包含重力的純加速度,這個加速度的坐標(biāo)系是和我們之前的重力和加速度是一種坐標(biāo)系。
8.Sensor.TYPE_ORIENTATION:
All values are angles in degrees.
所有的值都是角度。
values[0]: Azimuth, angle between the magnetic north direction and the y-axis, around the z-axis (0 to 359). 0=North, 90=East, 180=South, 270=West
值[0]:方位角,磁北極方向和y軸之間的夾角,圍繞z軸(0到359)。0=北,90=東,180=南,270=西
values[1]: Pitch, rotation around x-axis (-180 to 180), with positive values when the z-axis moves toward the y-axis.
俯仰,繞x軸旋轉(zhuǎn)(-180 ~ 180),z軸向y軸移動時為正值。
values[2]: Roll, rotation around the y-axis (-90 to 90) increasing as the device moves clockwise.
隨著設(shè)備順時針移動,繞y軸旋轉(zhuǎn)(-90到90)增加。
Note: This definition is different from yaw, pitch and roll used in aviation where the X axis is along the long side of the plane (tail to nose).
這個定義不同于航空中使用的偏航、俯仰和橫搖,在航空中X軸是沿著飛機的長邊(從機尾到機頭)。
Note: This sensor type exists for legacy reasons, please use rotation vector sensor type and getRotationMatrix() in conjunction with remapCoordinateSystem() and getOrientation() to compute these values instead.
Important note: For historical reasons the roll angle is positive in the clockwise direction (mathematically speaking, it should be positive in the counter-clockwise direction).
重要提示:由于歷史原因,橫滾角在順時針方向上是正的(從數(shù)學(xué)上講,它應(yīng)該在逆時針方向上是正的)。
筆記
- 1.注意這個東西他都是用度來作為單位的。
- 2.這里我們注意這里的航向角是0-360的,是和北極的夾角,這里我們要注意這個東西是在北極附近存在跳變的。
- 3.在數(shù)學(xué)上講,應(yīng)該是逆時針為正,但是由于歷史原因,橫滾角在順時針的方向是正的。正方向是遵循右手定則的,即:右手握住對應(yīng)的旋轉(zhuǎn)軸,大拇指指向正方向,那么四根手指指向的方向就是正方向了。這里我們從正方向看向版面,這個正方向正好是逆時針旋轉(zhuǎn),所以稱作逆時針。
- 4.這和我們在慣性導(dǎo)航當(dāng)中使用的航空相關(guān)的方式是不同的。所以需要注意。
9.Sensor.TYPE_ROTATION_VECTOR:
原文檔翻譯
The rotation vector represents the orientation of the device as a combination of an angle and an axis, in which the device has rotated through an angle θ around an axis <x, y, z>.
就是說用四元數(shù)描述手機當(dāng)前的orientation
The three elements of the rotation vector are <xsin(θ/2), ysin(θ/2), zsin(θ/2)>, such that the magnitude of the rotation vector is equal to sin(θ/2), and the direction of the rotation vector is equal to the direction of the axis of rotation.
旋轉(zhuǎn)矢量的三個元素是<xsin(θ/2), ysin(θ/2), zsin(θ/2)>,使得旋轉(zhuǎn)矢量的大小等于sin(θ/2),旋轉(zhuǎn)矢量的方向等于旋轉(zhuǎn)軸的方向。
The three elements of the rotation vector are equal to the last three components of a unit quaternion <cos(θ/2), xsin(θ/2), ysin(θ/2), zsin(θ/2)>.
旋轉(zhuǎn)矢量的三個元素等于單位四元數(shù)<cos(θ/2), xsin(θ/2), ysin(θ/2), zsin(θ/2)>的最后三個分量。
Elements of the rotation vector are unitless. The x,y, and z axis are defined in the same way as the acceleration sensor.
旋轉(zhuǎn)矢量的元素是無單位的。x、y和z軸的定義方式與加速度傳感器相同。
The reference coordinate system is defined as a direct orthonormal basis, where:
- X is defined as the vector product Y.Z (It is tangential to the ground at the device’s current location and roughly points East).
- Y is tangential to the ground at the device’s current location and points towards magnetic north.
- Z points towards the sky and is perpendicular to the ground.
World coordinate-system diagram.
將參考坐標(biāo)系定義為直接標(biāo)準(zhǔn)正交基,其中:
- X被定義為矢量積Y.Z(它與設(shè)備當(dāng)前位置的地面相切,大致指向東方)。
- Y與設(shè)備當(dāng)前位置的地面相切,指向磁北。
- Z指向天空,垂直于地面。世界坐標(biāo)系統(tǒng)圖。
(這里其實就是描述了一個東北天坐標(biāo)系)
values[0]: xsin(θ/2)
values[1]: ysin(θ/2)
values[2]: z*sin(θ/2)
values[3]: cos(θ/2)
values[4]: estimated heading Accuracy (in radians) (-1 if unavailable)
估計航向精度(弧度)(-1,如果不可用)是在SDK Level 18中添加的一個新值。
values[3], originally optional, will always be present from SDK Level 18 onwards.
最初是可選的,從SDK Level 18開始總是會出現(xiàn)。(最早是可以控制是否出現(xiàn)的,后來就是都會出現(xiàn),不用的話直接不拿就是了)
values[4] is a new value that has been added in SDK Level 18.
是在SDK Level 18中添加的一個新值。
筆記
- 1.前面三個是旋轉(zhuǎn)軸,后面那個是旋轉(zhuǎn)角解算
values[0]: x*sin(θ/2)
values[1]: y*sin(θ/2)
values[2]: z*sin(θ/2)
values[3]: cos(θ/2) - 2.value[4]表示的是一種估計的精度
- 3.sdk18之前可以選擇是不是提供最終的解算(value[3]),在18之后的sdk當(dāng)中這個是穩(wěn)定出現(xiàn)的。
- 4.關(guān)于四元數(shù)的各種可以參考:四元數(shù)介紹
- 5.我們可以看到在標(biāo)準(zhǔn)四元數(shù)的定義當(dāng)中(x,y,z)應(yīng)該是一個長度為一的標(biāo)準(zhǔn)向量,但是在安卓的官方文檔當(dāng)中卻沒有提起此事。我們實驗一下,可以看到,安卓當(dāng)中的(x,y,z)也是一個長度為1的標(biāo)準(zhǔn)向量。
- 6.另外官方還說了這里的(x,y,z)是和重力和加速度相同的坐標(biāo)系,其實就是載體坐標(biāo)系(b系)下的四元數(shù)。
- 7.這里我們注意這個東西從官方定義上來看和歐拉角表示的旋轉(zhuǎn)是一種意思,歐拉角是表示著從水平的狀態(tài)轉(zhuǎn)化到當(dāng)前狀態(tài)的變化,這里的四元數(shù)其實也表示著這種從水平狀態(tài)轉(zhuǎn)化到當(dāng)前狀態(tài)的方式。
- 8.他這里提到了兩個坐標(biāo)系,這里的表示坐標(biāo)系,其實是投影坐標(biāo)系,就是我們將表示這次變化的向量分解在這個投影坐標(biāo)系下。還有一個是相對坐標(biāo)系,我們知道我們世界上的任何運動都是相對的,所以當(dāng)我們應(yīng)當(dāng)確定相對坐標(biāo)系的問題,這里確定的相對坐標(biāo)系是n系,其實就是當(dāng)?shù)氐臇|北天坐標(biāo)系。這個其實好理解,其實也可以簡單的理解為相對于使用者的腳下站著的點的運動描述在使用手機的載體坐標(biāo)系下。
想要具體了解應(yīng)該去:慣性導(dǎo)航基礎(chǔ)
10.Sensor.TYPE_GAME_ROTATION_VECTOR:
Identical to Sensor.TYPE_ROTATION_VECTOR except that it doesn’t use the geomagnetic field.
和Sensor.TYPE_ROTATION_VECTOR相同,除了它不使用地磁場。
Therefore the Y axis doesn’t point north, but instead to some other reference, that reference is allowed to drift by the same order of magnitude as the gyroscope drift around the Z axis.
因此,Y軸并不指向北方,而是指向一些其他的參考點,該參考點被允許以與陀螺儀繞Z軸漂移相同的數(shù)量級漂移。
In the ideal case, a phone rotated and returning to the same real-world orientation will report the same game rotation vector (without using the earth’s geomagnetic field).
在理想的情況下,手機旋轉(zhuǎn)并返回到相同的現(xiàn)實世界方向?qū)蟾嫦嗤挠螒蛐D(zhuǎn)矢量(不使用地球的地磁場)。
However, the orientation may drift somewhat over time.
然而,方向可能會隨著時間的推移而有所漂移。
See Sensor.TYPE_ROTATION_VECTOR for a detailed description of the values. This sensor will not have the estimated heading accuracy value.
這個傳感器不會有估計的航向精度值。
筆記
- 1.這個東西不會有航向精度的返回
- 2.這個東西的y軸并不指向北方,而是指向參考點,所以相同的姿態(tài)變換總是得到相同的游戲四元數(shù)。
11.Sensor.TYPE_GYROSCOPE_UNCALIBRATED:
All values are in radians/second and measure the rate of rotation around the X, Y and Z axis. An estimation of the drift on each axis is reported as well.
所有值都以弧度/秒為單位,測量圍繞X、Y和Z軸的旋轉(zhuǎn)速率。還報告了每個軸上漂移的估計。
No gyro-drift compensation is performed. Factory calibration and temperature compensation is still applied to the rate of rotation (angular speeds).
不進行陀螺漂移補償。工廠校準(zhǔn)和溫度補償仍然適用于轉(zhuǎn)速(角速度)。
The coordinate system is the same as is used for the Sensor.TYPE_ACCELEROMETER Rotation is positive in the counter-clockwise direction (right-hand rule). That is, an observer looking from some positive location on the x, y or z axis at a device positioned on the origin would report positive rotation if the device appeared to be rotating counter clockwise. The range would at least be 17.45 rad/s (ie: ~1000 deg/s).
values[0] : angular speed (w/o drift compensation) around the X axis in rad/s
values[1] : angular speed (w/o drift compensation) around the Y axis in rad/s
values[2] : angular speed (w/o drift compensation) around the Z axis in rad/s
values[3] : estimated drift around X axis in rad/s
values[4] : estimated drift around Y axis in rad/s
values[5] : estimated drift around Z axis in rad/s
Pro Tip: Always use the length of the values array while performing operations on it. In earlier versions, this used to be always 3 which has changed now.
筆記
- 1安卓內(nèi)核不對其進行漂移的補償,但是傳感器本身就帶有的出廠就有的補償這里是不管的。
總結(jié)
以上是生活随笔為你收集整理的安卓惯性传感器(二)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 四元数表示旋转
- 下一篇: 对比学习系列论文CPC(二)—Repre