从iPhone加速度计数据计算加加速度和抖动 [英] Calculate Jerk and Jounce from iPhone accelerometer data

查看:258
本文介绍了从iPhone加速度计数据计算加加速度和抖动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试计算Jerk( http://en.wikipedia.org/wiki/混蛋(物理学))和跳动( http://en.wikipedia.org/wiki/Jounce )与来自加速度计的加速度数据.我想我已经弄明白了,但是我不确定我在做些什么是正确的.任何人都可以确认或否认我在做什么给我正确的值(我需要考虑时间吗?)

I am trying to calculate Jerk (http://en.wikipedia.org/wiki/Jerk_(physics)) and jounce (http://en.wikipedia.org/wiki/Jounce) with the acceleration data from the accelerometer. I think I have Jerk figured out, but I am not sure what I am doing for jounce is correct. Can anyone confirm or deny what I am doing is giving me correct values (Do I need to take into consideration time?)

#define kFilteringFactor    0.4
float prevAccelerationX;
float prevAccelerationY;
float prevAccelerationZ;

float prevJerkX;
float prevJerkY;
float prevJerkZ;



- (void)viewDidLoad
{
[super viewDidLoad];

prevAccelerationX = 0;
prevAccelerationY = 0;
prevAccelerationZ = 0;

prevJerkX = 0;
prevJerkY = 0;
prevJerkZ = 0;

[self changeFilter:[LowpassFilter class]];
[[UIAccelerometer sharedAccelerometer] setUpdateInterval:1.0 / kUpdateFrequency];
[[UIAccelerometer sharedAccelerometer] setDelegate:self];
}

// UIAccelerometerDelegate method, called when the device accelerates.
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
float pax = prevAccelerationX;
float pay = prevAccelerationY;
float paz = prevAccelerationZ;

float pjx = prevJerkX;
float pjy = prevJerkY;
float pjz = prevJerkZ;

prevAccelerationX = acceleration.x - ( (acceleration.x * kFilteringFactor) +
                                  (prevAccelerationX * (1.0 - kFilteringFactor)) );
prevAccelerationY = acceleration.y - ( (acceleration.y * kFilteringFactor) +
                                  (prevAccelerationY * (1.0 - kFilteringFactor)) );
prevAccelerationZ = acceleration.z - ( (acceleration.z * kFilteringFactor) +
                                  (prevAccelerationZ * (1.0 - kFilteringFactor)) );

// Compute the derivative (which represents change in acceleration).
float jerkX = ABS((prevAccelerationX - pax));
float jerkY = ABS((prevAccelerationY - pay));
float jerkZ = ABS((prevAccelerationZ - paz));


prevJerkX = jerkX - ( ( jerkX * kFilteringFactor) +
                     (prevJerkX * (1.0 - kFilteringFactor)));
prevJerkY = jerkY- ( (jerkY * kFilteringFactor) +
                                      (prevJerkY* (1.0 - kFilteringFactor)) );
prevJerkZ = jerkZ - ( (jerkZ * kFilteringFactor) +
                                      (prevJerkZ * (1.0 - kFilteringFactor)) );

// Compute the derivative (which represents change in acceleration).
float jounceX = ABS((prevJerkX - pjx));
float jounceY = ABS((prevJerkY - pjy));
float jounceZ = ABS((prevJerkZ - pjz));
}

推荐答案

为计算导数,是的,您需要考虑时间.基本上,您可以仅用(a2-a1)/采样时间来估计混响.它的时间导数类似.您使用kFilteringFactor的方式对我来说似乎很奇怪,但可能在您的特定采样时间内有效.您不应该使用ABS(),因为它对导数为负数是完全有效的.

In order to calculate derivatives, yes, you need to take time into consideration. Basically you can estimate jerk with just (a2-a1)/samplingtime. Its time derivative is similar. Your way of using kFilteringFactor seems weird to me but might work for your particular sampling time. You should not take ABS(), as it is perfectly valid for the derivative to be negative.

但是,一个大问题可能是采样频率低.手机中的采样频率通常约为60 Hz.这意味着您的实际加速带宽为30 Hz(奈奎斯特频率).将其减半,这就是您的混蛋带宽.将其减半并将您的带宽抖动,即7.5 Hz.粗略地讲.所有超过15 Hz的抽搐(仍然是一个有趣的词)和超过7.5 Hz的抖动不会消失,而是在结果之上具有别名.因此,不仅您会错过某些信息,而且您错过的信息实际上还会对您的结果造成更大的损害.正确完成后,您需要在每个导数之前进行低通滤波.

However, one big issue is probably going to be low sampling frequency. Sampling frequencies in phones are usually around 60 Hz. That means your actual bandwidth for acceleration is 30 Hz (the Nyquist frequency). Halve that and that's your jerk bandwidth. Halve that and your bandwidth for jounce, namely 7.5 Hz. Roughly speaking. All jerks (still a funny word) over 15 Hz and jounces over 7.5 Hz do not disappear but instead are aliased on top of your results. So not only you miss some information, the information you miss actually causes even more damage to your results. Properly done, you'd need low pass filtering before each derivative.

这篇关于从iPhone加速度计数据计算加加速度和抖动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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