Hey,
Thank you for this awesome project I'm learning a LOT from it!
I currently in the making of an app where I need to have the orientation of 2 different devices relative to the same reference frame, so I started with the earth reference frame and the closest I could get is the magnetic field, basically with your "Improved Orientation Sensor 1" implementaiton, which is great btw, but with 2 different devices ~10 meter away, I get some discrepancies, probably due to different readings or even manufacturers of the sensors giving different result on the magnetic pole.
I was wondering, will it be possible to add an extra layer of correction where we get the declination and apply a fix to the magnetic field? moving from Magnetic North ==> True North?
Ive read online that this formula apply:
Heading (magnetic) - Declination = True North
Im not sure yet how to get the declination but from my search its somehow possible with GeomagneticField class and with the onLocationChanged callback (I believe it all GPS related)
Do you think its possible to somehow integrate such thing in your code?
Thank you in advance.
Roy
Hi Roy,
thanks for your praise and the interest in this project.
The declination (discrepancy between magnetic north and true north) is dependent on your position on earth and the current date. I've been wanting to build something like a stable 3-d compass in this (fork-)project: https://bitbucket.org/apacha/stable-3d-compass/src/master/ but never finished it (mainly, because I had no idea how to do the visualization).
Check out the two commits before the last commit, where I've loaded the declination via the location service and used it to correct the orientation reading. If you want, please create another sensor, based on any of the existing absolute ones (Rotation Vector, Impr. Orientation 1, Impr. Orientation 2), where you also correct the declination and open a pull-request. I will gladly add it to the repository.
Coming back to your original use-case: Have you tried using the Android Rotation Vector? It's the standard sensor-fusion output by Android, upon which the other ones are based. If you have two devices, that are apart in that sensor reading due to noise, or cheap sensors, I'm afraid that a declination correction (which is just a constant shift along one axis) would not help to fix this, since both devices will still be off - just a little shifted.
Hope this helps.
Alex