首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iphone加速度计的最大采样率

iphone加速度计的最大采样率
EN

Stack Overflow用户
提问于 2011-08-02 18:34:09
回答 3查看 5.8K关注 0票数 3

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

所以有人能告诉我我们可以获得的最大更新率是多少,或者我如何才能获得更高的更新率。

EN

回答 3

Stack Overflow用户

发布于 2015-05-31 08:13:50

iPhone 6的最大加速度计和陀螺仪采样率为100 The 。您可以自己对此进行经验测试。下面是代码。

代码语言:javascript
复制
/******************************************************************************/
// 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]);
          }

       }
    }];
}
票数 3
EN

Stack Overflow用户

发布于 2018-06-14 07:28:28

尽管文档上写着The maximum frequency at which you can request updates is hardware-dependent but is usually at least 100 Hz.,但在我看来,的最大采样率仍然是100 is

我的解决方法是使用名为MotionGraphs的CoreMotion现有示例代码,并将startUpdates函数调整为如下所示:

代码语言:javascript
复制
func startUpdates() {
    guard let motionManager = motionManager, motionManager.isGyroAvailable else { return }

    sampleCount = 0
    let methodStart = Date()

    motionManager.gyroUpdateInterval = TimeInterval(1.0/100000.0) // Hardcoded to something verfy fast
    motionManager.startGyroUpdates(to: .main) { gyroData, error in
        self.sampleCount += 1
        //...view update code removed
        if (self.sampleCount >= 100) {
            let methodFinish = Date()
            let executionTime = methodFinish.timeIntervalSince(methodStart)
            print("Duration of 100 Gyro samples: \(executionTime)")
            self.stopUpdates()
        }
    }
}

我还设置了motionManager.deviceMotionUpdateInterval = TimeInterval(1.0/100000.0)作为很好的度量(以防它是全局速率)。

有了加速计和陀螺仪的代码,我确认iOS 11.4上的iPhone 8仍然可以达到100 in左右的最大速度。

代码语言:javascript
复制
Duration of 100 Accelerometer samples: 0.993090987205505
Duration of 100 Accelerometer samples: 0.995925068855286
Duration of 100 Accelerometer samples: 0.993505954742432
Duration of 100 Accelerometer samples: 0.996459007263184
Duration of 100 Accelerometer samples: 0.996203064918518

Duration of 100 Gyro samples: 0.989820957183838
Duration of 100 Gyro samples: 0.985687971115112
Duration of 100 Gyro samples: 0.989449977874756
Duration of 100 Gyro samples: 0.988754034042358
票数 3
EN

Stack Overflow用户

发布于 2011-08-02 21:24:13

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6910686

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档