【问题标题】:Reducing Noise in iPad Accelerometer减少 iPad 加速度计中的噪音
【发布时间】:2015-09-25 16:39:10
【问题描述】:

我只在一个方向从 iPad 的加速度计收集数据,而且结果非常嘈杂。我环顾四周寻找降噪滤波器,但没有找到我理解的(例如卡尔曼滤波器)。我想我有两个问题,是否存在与加速度计相关的实际显着噪声,如果是这样,我该如何减少它?即使您有噪声过滤器的链接并附上解释,我也将不胜感激。

我的应用程序本身是用 swift 编写的,我的数据分析是用 python 编写的,如果这很重要的话。

【问题讨论】:

    标签: python ios swift accelerometer noise


    【解决方案1】:

    我使用了一些简单的缓动来消除值中的任何尖峰。它会增加一点延迟,但您可以通过调整 easing 属性来确定延迟与平滑度的平衡,以适应您的应用程序。

    import UIKit
    import CoreMotion
    
    class MyViewController: UIViewController {
    
        var displayLink: CADisplayLink?
        let motionQueue = NSOperationQueue()
    
        var acceleration = CMAcceleration()
    
        var smoothAcceleration = CMAcceleration() {
            didSet {
                // Update whatever needs acceleration data
            }
        }
    
        var easing: Double = 10.0
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            self.displayLink = CADisplayLink(target: self, selector: "updateDisplay:" )
            self.displayLink?.addToRunLoop( NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode )
    
            var coreMotionManager = CMMotionManager()
            coreMotionManager.startAccelerometerUpdatesToQueue( self.motionQueue ) { (data: CMAccelerometerData!, error: NSError!) in
                self.acceleration = data.acceleration
            }
        }
    
        func updateDisplay( displayLink: CADisplayLink ) {
            var newAcceleration = self.smoothAcceleration
            newAcceleration.x += (self.acceleration.x - self.smoothAcceleration.x) / self.easing
            newAcceleration.y += (self.acceleration.y - self.smoothAcceleration.y) / self.easing
            newAcceleration.z += (self.acceleration.z - self.smoothAcceleration.z) / self.easing
    
            self.smoothAcceleration = newAcceleration
        }
    }
    

    【讨论】:

    • 看起来不错!我想一个后续问题是,有谁知道 iPad 加速度计的不确定性是什么?
    猜你喜欢
    • 2016-02-08
    • 2016-10-02
    • 2011-06-10
    • 2020-05-22
    • 2019-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多