简体   繁体   English

任意方向上的ios加速度计值

[英]ios accelerometer values at any orientation

Accelerometer values are provided with respect to the device orientation.. 加速度计值是相对于设备方向提供的。

My goal is to get these values irrespective of the device position. 我的目标是不管设备位置如何获得这些值。

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. 在考虑的情况下,如果将设备放置在车辆中,面朝上或水平放置,则沿y的加速度计值将指示车辆加速度。

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? 我们可以获取侧倾俯仰和偏航值,并将其转换为度数,以获取设备从正常面向上定向位置的角位移,但是在该随机定向时刻,我能否将加速度值转换为正常面向上方向位置值?

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. 基本上,我要遵循的是:获取设备的角位移->将在变形位置接收到的加速度计值转换为正常的朝上方位位置->获取Y以查看车辆的实际加速度,而与设备位置无关。

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 参考(第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;

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. 例如,通过使用“ CMAttitudeReferenceFrameXMagneticNorthZVertical”,无论设备处于什么位置,您从加速度获得的读数都是恒定的(它们与“ gravity”波纹管”和“ north”对准),我不记得确切的参考位置了但是我相信“电话顶部”指向北,而“电话屏幕”指向北。

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

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