4

My question is probably very simple but it could also be the case that I am completely wrong - therefore I decided to ask. In the end I will calculate my phone's orientation with the help of data from the gyroscope sensor. I know that I should use something like Kalman filter or complementary filter to cope with gyro drift. I will do this in a second step but the problem I am asking here is the same for both approaches. So, the real question is the following:

From the gyroscope I only get angular changes (after integration). So what I need is some initial value, I can add the currently measured change to. But how do I get this starting point? Do I use accelerometer and magnetometer to determine the phone's orientation? Or this there any better way?

If it matters, I use Android for this and have an implementation to determine the phone's orientation with the help of accelerometer and magnetometer but it is very inaccurate.

fkerber
  • 1,032
  • 9
  • 24

1 Answers1

1

Use an arbitrary orientation as inital oritentation.

Any reasonable filter has to recover from that and quickly converge to the actual orientation.

I used the filter described in the Direction Cosine Matrix IMU: Theory. I took care of the integral windup by bounding the TotalCorrection (page 27). Works like a charm!

Ali
  • 56,466
  • 29
  • 168
  • 265
  • This is very interesting. Then I will give it a try with the complementary filter and check how it will work. Thank you for your link. – fkerber Jan 16 '12 at 13:11
  • Don't forget: you have to make sure saturation won't happen. Bounding `TotalCorrection` was sufficient in my tests. Good luck! – Ali Jan 16 '12 at 14:16
  • Thanks for your comment. If I got it right, saturation is a problem that can occur, if the device is faster rotated (or better said more rotated in an amount of time) than the gyroscope can measure? And you got rid of the problem by bounding the total correction value? If I again got it right, this is no problem for me, as I won't do any balancing or correction but "simply" determin my phone's orientation. – fkerber Jan 16 '12 at 15:38
  • Sorry, my sloppiness. :( If you start from an arbitrary orientation, the `TotalCorrection` can become really HUGE because there is obviously a huge error in the orientation. In my experience, it is worth bounding the `TotalCorrection`. It makes convergence little slower but the filter will be bullet-proof. It requires tuning but which filter doesn't? Make your own experiments and you will see! – Ali Jan 16 '12 at 21:36
  • OK, what I was trying to say: take care of the [Integral windup](http://en.wikipedia.org/wiki/Integral_windup). One way or another, the issue will show up with any other filter, it has to recover from serious errors. If the integral windup is taken care of, you can happily start from any position, the filter will converge to the true orientation. – Ali Jan 16 '12 at 21:46
  • Hmm, I don't have a real idea what you mean, sorry. I now tried an approach like [this one](http://stackoverflow.com/questions/7553417/complementary-filter-gyro-accel-with-android/) and it seems to work for what I want to achieve. But this is strange when I consider your answer in this other topic. – fkerber Jan 16 '12 at 22:26
  • OK. Try to implement what is written in the DCMDraft2.pdf. If you have problems then look at the integral windup and its solutions. You may not have problems at all. – Ali Jan 17 '12 at 08:38