简体   繁体   English

在加速度计数据上应用一些过滤器-Windows Phone 8,C ++

[英]Applying some filter on my accelerometer data - Windows phone 8, C++

I'm placing data from the accelerometer X into a spaceship so that when you tilt the phone left and right, it rolls left and right (slightly). 我将来自加速度计X的数据放入一艘太空飞船中,以便当您左右倾斜手机时,它会左右摇摆(略微滚动)。

I have made a ratio because I want my spaceship to only rotate half way if the phone is tilted to -1 or 1 (full tilt). 我之所以设定一个比率,是因为如果手机倾斜到-1或1(全倾斜),我希望太空飞船仅旋转一半。

// accelerometer = Accelerometer::GetDefault();
// player->maxTitle = 0.5 (half of full accelerometer tilt)
double accelX = accelerometer->GetX();
player->currentRotation = ( accelX * player->maxTilt );

Originally this worked really jolty and poorly, so I had a play with the interval settings, vast improvement but still junk... it's rather sensitive now. 最初,这种方法确实工作得很愉快而且效果很差,所以我在间隔设置方面发挥了作用,虽然有了很大的改进,但仍然很烂……现在相当敏感。

accelerometer = Accelerometer::GetDefault();
int reportInterval = 16;
if( accelerometer->MinimumReportInterval > reportInterval )
{
    accelerometer->ReportInterval = reportInterval;
}

So I am assuming that I need to do some kind of low filter thing, wiener filter is it? 所以我假设我需要做某种低过滤的事情,维纳过滤器是吗? to smooth out the value... can I have some hints and tips on doing such an operation? 平滑价值...我可以在进行此类操作时获得一些提示和技巧吗?

I've tried a few formulas but am having difficulties getting them to work... http://forum.arduino.cc/index.php/topic,10716.0.html 我已经尝试了一些公式,但是很难让它们起作用... http://forum.arduino.cc/index.php/topic,10716.0.html

The discrete equivalent of a low-pass filter is to limit the difference between multiple readings. 低通滤波器的离散等效项是为了限制多个读数之间的差异。 This difference should not be too large, else you get the jerky behavior. 这种差异不应太大,否则会出现生涩的行为。 So, if it is, ignore the accelerometer value, and substitute the previous value plus the maximum allowed difference. 因此,如果是这样,则忽略加速度计值,并用先前的值加上最大允许差值代替。

Assume readings 1 6 9 and a maximum change of 4, you'd substitute the 6 with a 5. The differences have now become 4 4 instead of 5 3, which indeed is smoother. 假设读数为1 6 9且最大变化为4,则将6替换为5。现在差异变为4 4而不是5 3,这确实更平滑。 There are even smoother filters (using more state), but this should already help. 甚至还有更平滑的过滤器(使用更多状态),但这应该已经有所帮助。

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

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