Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sensor.TYPE_ROTATION_VECTOR has drift: Is there an alternative?

I'm trying out Sensor.TYPE_ROTATION_VECTOR on Android. It is supposed to use magnetfieldsensor, accelerometer and gyroscope to provide accurate rotation at all times. However, I notice enormous drift occurring on Moto G 2nd. I wonder if this is a device specific issue, or that this occurs on a lot of phones (which I would assume, although I am familiar that Moto G 2nd is a problematic case with it's gyroscope).

Is there an alternative form of sensor fusion, which is drift free (using magnetsensor)? I have tried Google Cardboard's sensor fusion as well, but it uses bias estimation, so presumably not entirely drift free (as the magnetfieldsensor is not used at this time it seems), although still A LOT better than TYPE_ROTATION_VECTOR.

like image 434
RobotRock Avatar asked Dec 07 '15 21:12

RobotRock


1 Answers

Platform/Hardware independent approach

  1. Gyro will, by definition, always drift.
  2. Magnetometer will, by definition, lack precision(*).
  3. Accelerometer, as far as detecting device position goes, is of no value whatsoever.

A general approach consists in:

  • listen to magnetometer changes notifications, with an amortization over time. This gives you large changes in device orientation changes.
  • listen to gyroscopic changes notifications, with an amortization over time. This gives you small changes in device orientation changes.

(*) In a cartesian physical world, the magnetometer should be enough, but in the earthling's universe, you need to compensate for the lack of magnetometer frequency of update, precision and external factors with the gyroscope, which provides immediate feedback.

like image 80
SwiftArchitect Avatar answered Oct 24 '22 22:10

SwiftArchitect