Florian Shu
Florian Shu

Reputation: 11

Difference between Sensor.TYPE_ROTATION_VECTOR and getOrientation by combining TYPE_ACCELEROMETER and TYPE_MAGNETIC_FIELD

I'm developing an application which steers a RC Car according to the actual position of a mobile phone.

Because TYPE_ORIENTATION is deprecated by Android (does someone know why exactly is it deprecated?) I'm using the RotationMatrix of (Magnetic_Field and Accelerometer) to get the orientation of the phone which works fine at the moment.

But during my research I come across with Sensor.TYPE_ROTATION_VECTOR for getting the orienation. Does this have some benefits or what methode is recommended to use?

Thanks

Upvotes: 1

Views: 1972

Answers (1)

wildcat12
wildcat12

Reputation: 1020

TYPE_ROTATION_VECTOR fuses multiple sensors together via OS level software. Here's a good tutorial explaining the differences, along with code samples and the author's findings: https://www.journal.deviantdev.com/android-compass-azimuth-calculating/

I have noticed that on my Nexus 5X, the azimuth (compass direction), becomes inaccurate from time-to-time. However, if I go to something else, like Google Maps, it also shows the incorrect compass direction. So this seems like either an issue with the device, its sensors or both.

TYPE_ROTATION_VECTOR does provide some nice smoothing of the values, and then you can just add a low-pass filter if you want additional smoothing. Good luck!

Upvotes: 2

Related Questions