iphone - iPhone 中加速度计的最大采样率

标签 iphone ios4 accelerometer uiaccelerometer

有人知道iphone加速度计的最大采样率是多少吗? 我想要有高更新率。我将其 updateInterval 设置为 1.0/300.0 但似乎我没有得到那么多的更新率。

那么任何人都可以告诉我我们可以获得的最大更新率是多少或者我如何获得高更新率。

最佳答案

iPhone 6 上的最大加速度计和陀螺仪采样率为100Hz。您可以自己凭经验进行测试。这是代码。

/******************************************************************************/
// First create and initialize two NSMutableArrays. One for accel data and one
// for gyro data. Then create and initialize CMMotionManager.  Finally,
// call this function

- (void) TestRawSensors
{
   speedTest = 0.0001; // Lets try 10,000Hz
   motionManager.accelerometerUpdateInterval = speedTest;
   motionManager.gyroUpdateInterval = speedTest;


    [motionManager startAccelerometerUpdatesToQueue: [NSOperationQueue currentQueue]
    withHandler: ^(CMAccelerometerData  *accelerometerData, NSError *error)
    {
       [rawAccelSpeedTest addObject: [NSNumber numberWithDouble: accelerometerData.timestamp]];
       [rawAccelSpeedTest addObject: [NSNumber numberWithDouble: accelerometerData.acceleration.x]];

       if (error)
       {
          NSLog(@"%@", error);
       }

       if (rawAccelSpeedTest.count > 100)
       {
          [motionManager stopAccelerometerUpdates];

          for (uint16_t i = 0; i < rawAccelSpeedTest.count; i+=2)
          {
             NSLog(@"Time: %f   Accel: %f", [rawAccelSpeedTest[i] doubleValue],
                                            [rawAccelSpeedTest[i+1] doubleValue]);
          }
       }
    }];


   [motionManager startGyroUpdatesToQueue: [NSOperationQueue currentQueue]
                              withHandler: ^(CMGyroData *gyroData, NSError *error)
    {
       [rawGryoSpeedTest addObject: [NSNumber numberWithDouble: gyroData.timestamp]];
       [rawGryoSpeedTest addObject: [NSNumber numberWithDouble: gyroData.rotationRate.x]];

       if (error)
       {
          NSLog(@"%@", error);
       }

       if (rawGryoSpeedTest.count > 100)
       {
          [motionManager stopGyroUpdates];

          for (uint16_t i = 0; i < rawGryoSpeedTest.count; i+=2)
          {
             NSLog(@"Time: %f   Rate: %f", [rawGryoSpeedTest[i] doubleValue],
                                           [rawGryoSpeedTest[i+1] doubleValue]);
          }

       }
    }];
}

关于iphone - iPhone 中加速度计的最大采样率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6910686/

相关文章:

ios - Autolayouts 设置纵向和横向 View iOS

iphone - 使用 GPUImageRGBFilter

iphone - 如何在iPhone SDK中为pickerview设置setInputAccessoryView

android - Android 设备中的加速度计得到多广泛的支持?

algorithm - 使用传感器融合的运动跟踪

android - SENSOR_ACCELEROMETER (Android) 中的准确度始终为 0

iphone - uisegmentedcontrol 手动设置 selectedindex 不工作

iphone - Xcode 中的 Target 到底是什么?

iphone - 如何将表格单元格分隔符制作成我们想要的 View

objective-c - 是什么导致表格单元格以随机/未知模式显示?