简体   繁体   中英

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).

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).

// 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

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. There are even smoother filters (using more state), but this should already help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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