6

I am using LG Optimus 2x smartphone(Gyroscope and Accelerometer sensor) for positioning.

I want to get correct rotation angles from gyroscope that can be used later on for body to earth coordinate transformation. My question is that

How I can measure and remove the drift in gyro sensor.

The one way is to take the average of gyro samples (when mobile is in static condition) for some time and subtracting from current sample, which is not good way.

When the mobile is in rotation/motion how to get the drift free angles?

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
Navigator
  • 61
  • 1
  • 2
  • 3

3 Answers3

2

As far as I know, either the Kalman filter or something similar is implemented in the SensorManager. Check out Sensor Fusion on Android Devices: A Revolution in Motion Processing.

You are trying to solve a problem that is already solved.

Ali
  • 56,466
  • 29
  • 168
  • 265
  • I don't think so that kalman Filter is actually implemented in Sensor Manager. you can view the source at http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3.4_r1/android/hardware/SensorManager.java#SensorManager regards Navigator – Navigator Feb 08 '12 at 21:48
  • When I looked at the source code, it looked like a Kalman filter to me, but maybe I was fooled. But at any rate, modern Android os employs Sensor Fusion. OP should look at the GRAVITY sensor instead of the ACCELEROMETER sensor. The GRAVITY sensor is a virtual sensor created by combining accelerometer and gyro. It's essentially the linear acceleration sensor with motion effects filtered out. – Edward Falk Aug 09 '12 at 00:13
2

I am the author of a compass application that integrates data from magnetic and gyroscope sensors (steady compass). I have tested this application mostly on a LG Optimus black (the device that you can see on the video) running Android 2.2, so I am going to share my experiences:

  • Gyroscope readings are very accurate. This sensor is just the opposite to accelerometer and magnetic sensors which give readings with a lot of jitter.
  • The readings from the gyroscope (i.e. the angular speed) does not drift at all. You will have a drift in the estimation of the orientation if you just integrate gyroscope readings. Since you are integrating samples in different times, you will obtain just an approach that will degrade after every integration step.
  • In order to avoid such a drift in the orientation estimation, you must consider other input sources to correct the results coming from gyroscope data integration. The solution is the integration of data coming from the orientation sensor (magnetic + acceleration) and data coming from the gyroscope.

Be careful with LG phones: According to the Android API, gyroscope will return data in rad/s. The LG Optimus Black with Froyo gives readings in degrees/s. The update to Android 2.3 has just been released for such phone. I have to test whether the new version behaves according to the specifications.

What Android version does your phone have? Have you tested any application using gyroscope? Did you get the expected results?

jap1968
  • 7,747
  • 1
  • 30
  • 37
  • Hi jap1968, I am using the same LG optimus 2x. Originally there was android 2.2 and i noticed the similar observation that there is no drift in gyro signal but only due to vibration and jerk and drift due to integration. When i upgraded to android 2.3.4, i noticed two things , first gyro values are in rad/sec and secondly now gyro has some offset value even when mobile is at rest, earlier in Froyo 2.2 version Gyro signal was almost zero and there was no offset. Did u observe the same thing? plz comment if u tested.regards Navigator – Navigator Feb 08 '12 at 21:36
  • The local provider (Orange Spain) has not released the upgrade, so the Optimus Black used to test is still running on Android 2.2. I have also tested the compass on other devices having gyroscope: Tablets running Android 3.1 and 3.2, as well as Samsung Galaxy S II running Android 2.3.x. In some devices the gyroscope is really very accurate while in others shows readings not even near to zero with the device not moving at all. The result: some users give the application 5 stars due to nice behavior while others give one star due to bad behavior. – jap1968 Feb 09 '12 at 08:40
1

Basically gyros drift over long time periods. Whereas accelerometers have no drift but tend to be unstable. By combining information from both sensors using a Kalman filter you can obtain a accurate attitude. For some this less complex you could also use a Complementary Filter.

See this post for more info: Combine Gyroscope and Accelerometer Data

Community
  • 1
  • 1
Frohnzie
  • 3,559
  • 1
  • 21
  • 24