Wednesday, 24 October 2018

Implementing current cardinal direction method with TYPE_ROTATION_VECTOR while standing still?

There appear to be many old examples of getting the current cardinal direction on Android devices, but an official solution provided by Google does not appear to be in their documentation.

The oldest reference Sensor.TYPE_ORIENTATION which is deprecated, more recent ones mention Sensor.TYPE_ACCELEROMETER and Sensor.TYPE_MAGNETIC_FIELD(which I have tried with little success - accuracy shifts rapidly depending on device orientation). I've been experimenting with implementations using those two like this. I've even seen some with TYPE.GRAVITY.

The most recent seem to suggest TYPE_ROTATION_VECTOR which apparently is a fused sensor(reference), but example implementations do not seem to be readily available.

I need to use these position/motion sensors, and not GPS, because the user will not be moving during the time when this measurement is needed. Also need the measurement to be stable regardless of whether phone is flat, or vertical(as if you are taking a photo)

After we pull the degree measurement somehow, converting to cardinal direction seems to be the easy part.(https://stackoverflow.com/a/25349774/1238737)

Previous solutions

  1. How to get Direction in Android (Such as North, West)
  2. https://stackoverflow.com/a/11068878/1238737


from Implementing current cardinal direction method with TYPE_ROTATION_VECTOR while standing still?

No comments:

Post a Comment