Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative for TYPE_GAME_ROTATION_VECTOR

I am trying to control a vehicle's steering using android device rotation.

TYPE_GAME_ROTATION_VECTOR is not present on Samsung Galaxy S4 (running Android 4.4.2). . .I confirmed that by getting list of all available sensors.

Is there a way I could discard Magnetometer data from TYPE_ROTATION_VECTOR?

TYPE_GAME_ROTATION_VECTOR is same a TYPE_ROTATION_VECTOR except the magnetometer input being ignored.

Can that be accomplished by doing sensor fusion for TYPE_GRAVITY and TYPE_GYROSCOPE?

Any references would be appreciated.

like image 489
Manmohan Bishnoi Avatar asked Nov 02 '14 08:11

Manmohan Bishnoi


1 Answers

You can definitely use a combination of Accelerometer and Gyroscope to detect device rotation ("Gravity" is a fusion of the two where gyroscope is used to make the data smoother and more responsive).

From my own tests, the Game Rotation Vector sensor is affected by magnetic field data (possibly indirectly through gyro bias elimination), so you should probably find another solution (my test was tracking the rotation while in a car compared to just walking around, turns out the magnetic field of the car interfered with the rotation - I made a video comparing Game Rotation Vector data with just integrating the gyro output here).

If you go without magnetic field data, you will always have drift (slow buildup of rotation error in horizontal plane). The main part of what you need to do is to integrate gyroscope data over time (see Google's own code on using gyroscope data for keeping track of rotation here).

To prevent vertical drift, you have to use the accelerometer to keep track of where gravity is relative to your device and combine this with gyroscope data. A commonly suggested way to do this is to use a Kalman Filter, but depending on your application, that may be unnecessarily complicated, so I'd suggest using what's known as a Complementary Filter, which can be described as fusing data from a low pass filtered, noisy, but stable signal (accelerometer) and a high pass fitler on a responsive, but drifting, signal (gyroscope). A great resource on kalman and complementary filters can be found here.

like image 58
Svj0hn Avatar answered Sep 30 '22 02:09

Svj0hn