I have a device with an IMU6 sensor. When it is laying on the table, the gyroscope and accelerometer data are constantly changing. The values between two measurements are similar, but they are never equal. There is always noise.

I need a formula for calculating the real angles to which the device was rotated if rotation has really happened. This will be used for game controlling, so I need as small an input lag as possible (I can't accumulate inputs to a buffer and then smooth them; that will give too big a delay).

How do I calculate the real rotation angles?

  • 2
    \$\begingroup\$ There is always the noise exist. Welcome to reality. Out of the door, line on the left, one cross each. \$\endgroup\$ Dec 14, 2021 at 19:25
  • \$\begingroup\$ Start with learning about Kalman filter. \$\endgroup\$
    – Eugene Sh.
    Dec 14, 2021 at 19:33
  • \$\begingroup\$ Just an IMU can't tell the difference between internal bias and slow rotation or acceleration. You need to either make assumptions (i.e., it's neither rotating nor moving on average) or you need some absolute reference -- either compass direction or position (from which you can deduce compass direction), or both. What do you have to use beyond the IMU? \$\endgroup\$
    – TimWescott
    Dec 14, 2021 at 19:57

1 Answer 1


No matter what you do, every measurement is noisy.

If your noise is too large, for your application, you need to filter it, and combine multiple observations.

But any kind of filtering has to be causal in reality (no effect without prior cause), and hence leads to lag. No way in this world around that! However, averaging is a pretty bad filter, so maybe a different filter would fit you better. But it's impossible to advise you on a better filter with the info you've given: we don't know your noise PSD, how sensitive your game is in terms of which frequencies, and what your acceptable lag is for different frequencies.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.