我使用此
获得所有3个轴timer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(Accelerometer) userInfo:nil repeats:YES];
[timer fire];
修改
-(void)Accelerometer
{
float accex1 = motionManager.accelerometerData.acceleration.x;
float accey1 = motionManager.accelerometerData.acceleration.y;
float accez1 = motionManager.accelerometerData.acceleration.z;
float mAccelCurrent1 = sqrtf(pow((accex1 * accex1),2) + pow((accey1 * accey1),2) + pow((accez1 * accez1),2));
float Acc = fabsf(mAccelCurrent1-Prv_Acceleration);
Prv_Acceleration = mAccelCurrent1;
[R1_Changes addObject:[NSString stringWithFormat:@"%f",Acc]];
}
感谢 Hanno Binder 现在我得到了Accretion。现在
Q2。我如何在1分钟或10分钟内获得总增加量?
先谢谢.....
答案 0 :(得分:0)
你的意思是“总加速度”,也许是速度?如果你取每个加速度值并乘以两个读数之间的时间,比如你的例子中的每一分钟,那就会给你一个近似的速度(假设你知道你的起始速度是多少)。
float self.totalAcc = 0.0; // EDITED HERE
-(void)Accelerometer
{
float accex1 = motionManager.accelerometerData.acceleration.x;
float accey1 = motionManager.accelerometerData.acceleration.y;
float accez1 = motionManager.accelerometerData.acceleration.z;
float mAccelCurrent1 = sqrtf(pow((accex1 * accex1),2) + pow((accey1 * accey1),2) + pow((accez1 * accez1),2));
float Acc = fabsf(mAccelCurrent1-Prv_Acceleration);
totalAcc += (mAccelCurrent1 - prvAcceleration) * timeChange // EDITED HERE
Prv_Acceleration = mAccelCurrent1;
[R1_Changes addObject:[NSString stringWithFormat:@"%f",Acc]];
}
速度是加速度的时间积分。不知道你有多少物理/微积分,但你可以在这里了解更多:khanAcademy - Integrals