方向传感器

方向传感器简称为O-sensor,返回三轴的角度数据,方向数据的单位是角度。

为了得到精确的角度数据,E-compass需要获取G-sensor的数据,
经过计算生产O-sensor数据,否则只能获取水平方向的角度。

方向传感器提供三个数据,分别为azimuth、pitch和roll :
azimuth:方位,返回水平时磁北极和Y轴的夹角,范围为0°至360°。
0°=北,90°=东,180°=南,270°=西。
pitch:x轴和水平面的夹角,范围为-180°至180°。
当z轴向y轴转动时,角度为正值。
roll:y轴和水平面的夹角,由于历史原因,范围为-90°至90°。
当x轴向z轴移动时,角度为正值。
==========================================================
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

values[1]: Pitch, rotation around x-axis (-180 to 180), with positive values when the z-axis moves toward the y-axis.

values[2]: Roll, rotation around y-axis (-90 to 90), with positive values when the x-axis moves toward the z-axis.
=========================================================

电子罗盘在获取正确的数据前需要进行校准,通常可用8字校准法。
8字校准法要求用户使用需要校准的设备在空中做8字晃动,
原则上尽量多的让设备法线方向指向空间的所有8个象限。
手机中使用的电子罗盘芯片有AKM公司的897X系列,ST公司的LSM系列以及雅马哈公司等等。
由于需要读取G-sensor数据并计算出M-sensor和O-sensor数据,
因此厂商一般会提供一个后台daemon来完成工作,电子罗盘算法一般是公司私有产权。

posted @ 2013-09-09 12:40  pmtoam  Views(1376)  Comments(0)    收藏  举报