安卓传感器
我有一个关于传感器的非常基本的问题:
磁传感器返回手机初始方向的读数还是世界坐标的读数?
加速度计怎么样?它们是否返回先前读数的值,或者每个值都是相对于世界坐标系的独立加速度?
我知道陀螺仪返回相对于手机初始方向的读数。那么,如何将陀螺仪的偏航、俯仰和滚动读数转换为智能手机磁传感器的方位角、俯仰和滚动读数(我使用的是 HTC Hero)
谢谢!
I have a very basic question about Sensors:
Do magnetic sensors return readings w.r.t the phone's initial orientation or w.r.t the world coordinates?
What about accelerometers? Do they return values w.r.t their previous readings or is each value an independent acceleration relative to the world coordinate system?
I know that gyros return readings relative to the phone's initial orientation. So, how do I convert the yaw, pitch and roll readings from a gyro into the azimuth, pitch and roll readings from a magnetic sensor of a smartphone (I'm using HTC hero)
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如前所述,陀螺仪测量角速度。
返回的第三个值 (values[2]) 是关于
z 轴。您可以将该值与磁力计的初始值一起使用
计算当前航向: Theta(i+1) = Theta(i) + Wgyro*deltaT
您可以从“方向”测量中接收初始航向方向(值[0])
该测量仅取决于磁力计。 (您可以将磁铁或第二部手机靠近智能手机并观察输出
的疯狂程度)“方向”的第二个和第三个值取决于
加速度计。由于加速度计测量重力,因此可以计算
来自 Y 轴和 X 轴加速度计读数的俯仰角和横滚角。
希望这对
Ariel有帮助
As mentioned, the gyroscope measures the angular velocity.
The third value returned (values[2]) is the angular velocity regarding the
z axis. You can use this value together with the initial value from the magnetometer to
calculate current heading: Theta(i+1) = Theta(i) + Wgyro*deltaT
You can receive initial heading orientation from 'Orientation' measurement (values[0])
This measurement is dependent only on the magnetometer. (you can put a magnet or a second phone close to the Smartphone and watch the output going crazy)
The second and third values of the 'Orientation' are dependent on the readings of the
Accelerometer. Since the Accelerometer measures gravity, it is possible to calculate
the pitch and roll angles from the Accelerometer readings in Axis Y and X.
Hope this helps
Ariel
Android 传感器(直至 FroYo)为应用程序提供“原始”数据。
只涉及最低限度的“烹饪”(即加工)。
加速和指南针装置提供绝对加速度和分别为磁力数据。
陀螺仪提供相对角速度。
陀螺仪不提供任何特定状态/位置的相关数据。
您需要了解的是陀螺仪数据是角速度。
角速度很简单,就是手机旋转的速度(以度/秒为单位)。
因此,一旦你保持不动,陀螺仪就会显示 (0,0,0) &
当你旋转时,你会知道它的旋转速度。
这一直持续到你再次保持不动
当陀螺仪读数再次变为(0,0,0)时。
理论上陀螺仪可以用来“校准”罗盘。
但要做到这一点,您需要进行大量的实验。
理想的摆弄位置是传感器 HAL。
注意:您需要打开所有传感器硬件,即使
仅需要指南针数据。因为您将交叉引用
陀螺仪/加速度数据。这将意味着更大的功耗&
电池寿命极差。所有连续开启的传感器都可以
标准 Android 手机的电池在 4-5 小时内耗尽。
您可以此处了解更多 Android 传感器。
Android Sensors (upto FroYo) provide the application with "raw" data.
There is bare minimum of "cooking" (ie processing) involved.
The accel & compass device provide absolute accel & magnetic data respectively.
The gyroscope provides relative angular velocity.
Gyroscopes do NOT provide relative data wrt any specific state/position.
What you need to understand is that gyroscopic data is angular-velocity.
Angular velocity is simply, how fast the phone is rotating (in degrees-per-second).
So once you hold it still, gyro says (0,0,0) &
as you rotate, you get how fast it is rotating.
This continues until u again hold it back still
when the gyro reading again becomes (0,0,0).
Theoretically the gyro can be used in "callibrate" the compass.
But to do so would require a lot of experimentation on your part.
The ideal place to fiddle around would be the sensor-HAL.
NOTE: You would need to turn-ON all the sensor h/w even if
ONLY compass data is reqd. As you will be cross-referencing
the gyro/accel data for that. This will mean larger power consumption &
extremely poor battery life. All the sensors turned on continuously can
drain the battery of a standard Android phone in 4-5hrs.
You can read more Android Sensors here.