简体   繁体   English

Windows Phone加速度计抖动

[英]windows phone accelerometer jitter

I would like to get accelerometer readings every 10ms from my Windows Phone 8, but instead I observe some jitter: the spacing between readings will be 8,10,12,9, or the like. 我想从Windows Phone 8每10毫秒获取一次加速度计读数,但我观察到一些抖动:读数之间的间隔将是8,10,12,9,等等。 So approximately 10, but not exactly. 大约是10,但不完全是。

I was wondering whether someone could suggest a way to get more reliable readings. 我想知道是否有人可以提出一种获取更可靠读数的方法。

The core of my code looks like this: 我的代码的核心如下所示:

var accelerometer = Windows.Devices.Sensors.Accelerometer.GetDefault();
accelerometer.ReadingChanged += accelerometer_ReadingChanged;
accelerometer.ReportInterval = 10;

The phone reports a MiminumReportingInterval of 10, so that should be fine. 电话报告的MiminumReportingInterval为10,所以应该没问题。 My callback just adds the numbers to a list, which I will send over the network at the end. 我的回调仅将数字添加到列表中,最后我将通过网络发送该列表。

I am looking at the time in AccelerometerReadingChangedEventArgs.Timestamp, and that's where I see that the interval isn't always 10ms. 我正在查看AccelerometerReadingChangedEventArgs.Timestamp中的时间,在那儿我看到间隔并不总是10ms。 Here's what the times looked like in the latest measurements: 105,118,128,134,146,157,163,177,187,198,208,213,232,238,245,255,263,279,285,295,303,313,324,334,345,355,363,375,385 这是最新测量中的时间:105,118,128,134,146,157,163,177,187,198,208,213,232,238,245,255,263,279,285,295,303,313,324,334,345,355,363,375,385,385

So: is there something I can do to get more precisely spaced measurements? 所以:我可以做些什么来获得更精确地间隔的测量? Or is this just the best this particular hardware can do? 还是这仅仅是该特定硬件可以做的最好的事情?

There is a great article on Windows Phone Developer Blog which covers accelerometer in details. Windows Phone Developer博客上一篇很棒的文章 ,详细介绍了加速度计。

One of the points of the article is that, yes, the stream of values can and most probably will be 'jittery' so you should implement some method of filtering. 文章的要点之一是,是的,值的流可能并且很可能是“抖动的”,因此您应该实现某种过滤方法。 One such method is a low pass filter. 一种这样的方法是低通滤波器。

The smoother the data after filtering, the bigger the delay will be between the actual change and the reading. 过滤后的数据越平滑,实际变化和读数之间的延迟就越大。 In other words, if you used accelerometer in a game as a 'steering wheel', a lot of filtering will result in late turning of a car, but no filtering will probably result in a jittery car. 换句话说,如果您在游戏中将加速计用作“方向盘”,则很多过滤将导致汽车晚转,但没有过滤可能会导致汽车抖动。 So, the best is to set it somewhere in between, depending on the use case. 因此,最好是根据使用情况将其设置在两者之间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM