任何方向的ios加速度计值 [英] ios accelerometer values at any orientation

查看:269
本文介绍了任何方向的ios加速度计值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据设备方向提供加速度计值。

Accelerometer values are provided with respect to the device orientation..

我的目标是获取这些值,而不管设备位置如何。

My goal is to get these values irrespective of the device position.

在考虑的情况下,如果将设备放置在车辆中,面朝上或水平放置,加速计值沿y表示车辆加速度。

In a considered scenario, if the device is placed in a vehicle, placed face up or horizontally, the accelerometer values along y would indicate the vehicles acceleration.

如果将设备放置在随机方向的手套箱中怎么办?
我们可以获得滚动俯仰和偏航值,并将它们转换为度数以获得设备从正常面朝上定位位置的角位移,但是在该随机定向时刻,我可以将加速度值转换/转换为正常的面朝上定位位置值?

What if the device is placed in the glove box with random orientation? We can get the roll pitch and yaw values, and convert them into degrees to get the angular displacement of device from the normal face up orientation position but at that random orientation moment, can I get/convert the acceleration values into the the normal face up orientation position values?

基本上我所遵循的是:获取设备的角位移 - >将在失真位置接收的加速度计值转换为正常值面向上方向位置 - >获取Y以查看车辆的实际加速度,而不管设备位置如何。

Basically what I am following is: get the angular displacement of device -> convert the accelerometer values received at the distorted position to a normal face up orientation position -> get the Y to see the actual acceleration of vehicle irrespective of the device position.

参考(第3.1点): http://www.itsasiapacificforum2014.co.nz/files/3314/0194/4873/摘要_-_ Automatic_Accelerometer_Reorientation_for_Driving_Event_Detection_Using_Smartpho ne_by_Passakon_Prathombutr.pdf

Reference (Point 3.1): http://www.itsasiapacificforum2014.co.nz/files/3314/0194/4873/Abstract_-_Automatic_Accelerometer_Reorientation_for_Driving_Event_Detection_Using_Smartphone_by_Passakon_Prathombutr.pdf

推荐答案

实际上非常简单,只需使用参考框架开始生成设备动作更新:

Its quite simple actually, just start generating device motion updates using a reference frame:

- (void)startDeviceMotionUpdatesUsingReferenceFrame:(CMAttitudeReferenceFrame)referenceFrame

根据您想要达到的目的,您可以选择其中一个不同的选项

Depending on what you want to achieve you can select one of the different options

typedef enum {
   CMAttitudeReferenceFrameXArbitraryZVertical = 1 << 0,
   CMAttitudeReferenceFrameXArbitraryCorrectedZVertical = 1 << 1,
   CMAttitudeReferenceFrameXMagneticNorthZVertical = 1 << 2,
   CMAttitudeReferenceFrameXTrueNorthZVertical = 1 << 3
} CMAttitudeReferenceFrame;

例如,通过使用CMAttitudeReferenceFrameXMagneticNorthZVertical,您从加速度获得的读数将是恒定的,无论设备位置(它们与重力对齐前方和北方)。我不记得确切的参考位置,但我相信手机顶部指向北方,而手机屏幕指向up。

For example, by using "CMAttitudeReferenceFrameXMagneticNorthZVertical" the readings you get from the acceleration would be constant regardless of the device position (they get aligned with "gravity" bellow" and "north" in front). I don't remember the exact reference position but i believe the "top of the phone" points north while the "screen of the phone" points up.

这篇关于任何方向的ios加速度计值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆