Strange behavior of magnetic field measurements during device rotation

Situation:

I am trying to create an internal localization system using changes in the magnetic field inside the building using fingerprinting. As a sensor, I use my Galaxy Nexus mobile phone.

Basically, the idea of ​​getting my fingerprints is to measure the magnetic field in the x, y, and z directions, respectively, and rotate the vector in the orientation of the mobile device to bring the vector into the world coordinate system. To find someone, he also measures the magnetic field, rotates the vector and sends it to the server, where I will run location algorithms.

My problem:

When I measure a magnetic field in the same place in different orientations, I do not get the same result after the rotation of the vector. Even field strength is not the same.

To show this, I took four measurements in the same position and turned the mobile phone around its z axis ( standard Android specification ) 90, 180 and 270 degrees counterclockwise, respectively. The results can be seen on this β€œtable” and on the Matlab graphs (see Link) below (if you want other views to let me know)

Edit: To be more precise: what I really did was that I defined my own coordinate system called let system of system. I took one wall of the room and defined it as north. The U-axis of my phone is aliens with this wall (in the first position) while it was flat on the table. Therefore, the positive z axis indicates the sky, and the x axis is defined as 90 degrees walls. Vectors with the name "Raw" are the original values ​​of the phone and therefore they are located in the coordinate system of the phone. A vector called "Rotation" rotates into this "room coordinate system." On the graph, the dotted vectors are the original vectors, and the solid vectors are rotated.

╔═════════════╦════════╦════════╦════════╦══════════╗ β•‘ Vector β•‘ X β•‘ Y β•‘ Z β•‘ Strength β•‘ ╠═════════════╬════════╬════════╬════════╬══════════╣ β•‘ 0Β°Raw β•‘ 17.55 β•‘ 8.21 β•‘ -36.83 β•‘ 41.62 β•‘ β•‘ 0Β°Rotated β•‘ 17.55 β•‘ 8.21 β•‘ -36.83 β•‘ 41.62 β•‘ β•‘ 90Β°Raw β•‘ 15.74 β•‘ -11.36 β•‘ -36.86 β•‘ 41.66 β•‘ β•‘ 90Β°Rotated β•‘ 11.36 β•‘ 15.74 β•‘ -36.86 β•‘ 41.66 β•‘ β•‘ 180Β°Raw β•‘ -65.06 β•‘ -16.18 β•‘ -44.79 β•‘ 80.63 β•‘ β•‘ 180Β°Rotated β•‘ 65.06 β•‘ 16.18 β•‘ -44.79 β•‘ 80.63 β•‘ β•‘ 270Β°Raw β•‘ 6.38 β•‘ 61.95 β•‘ -46.37 β•‘ 77.64 β•‘ β•‘ 270Β°Rotated β•‘ 61.95 β•‘ -6.38 β•‘ -46.37 β•‘ 77.64 β•‘ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β• 

enter image description hereenter image description here

As you can see, even after their rotation, they really do not match. Do you have any idea why this might be? What would I not have thought? Thank you very much in advance!

Edit2:

Second experiment

I did another experiment with the best results, but still not as good as I expected. This time the direction is not as constant as it should be. This time I took my measurements outdoors. I crossed the Y axis to the true north and laid it on the ground. I turned it about 3 times 90 degrees counterclockwise. I took a photo of the position of the mobile phone with another camera and measured the actual rotation using Photoshop. The results that you can see on the table and in the graphs below:

 ╔═════════════╦════════╦════════╦════════╦══════════╗ β•‘ Vector β•‘ X β•‘ Y β•‘ Z β•‘ Strength β•‘ ╠═════════════╬════════╬════════╬════════╬══════════╣ β•‘ 0Β°Raw β•‘ 1.22 β•‘ 20.31 β•‘ -57.53 β•‘ 61.02 β•‘ β•‘ 0Β°Rotated β•‘ 1.22 β•‘ 20.31 β•‘ -57.53 β•‘ 61.02 β•‘ β•‘ 104Β°Raw β•‘ 25.92 β•‘ 5.66 β•‘ -57.53 β•‘ 63.35 β•‘ β•‘ 104Β°Rotated β•‘ -11.93 β•‘ 23.70 β•‘ -57.53 β•‘ 63.35 β•‘ β•‘ 204Β°Raw β•‘ 5.42 β•‘ -16.86 β•‘ -59.67 β•‘ 62.24 β•‘ β•‘ 204Β°Rotated β•‘ -11.90 β•‘ 13.12 β•‘ -59.67 β•‘ 62.24 β•‘ β•‘ 290Β°Raw β•‘ -12.18 β•‘ 0.73 β•‘ -57.85 β•‘ 59.12 β•‘ β•‘ 290Β°Rotated β•‘ -3.64 β•‘ 11.64 β•‘ -57.85 β•‘ 59.12 β•‘ β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β• 

enter image description hereenter image description here

Additional notes:

Values ​​are averaged over a couple of seconds. So this is not a noise issue.

I know that I can not use the getOrientation function because it uses a magnetic field to calculate the orientation, and this does not make sense, since I want to find variations of the magnetic field. For the example above, I manually created a rotational quaternion.

+6
source share
1 answer

Make sure that you control the accuracy of the sensors using the onAccuracyChanged(Sensor sensor, int accuracy) method. I find that with my Nexus 10 tablet, accuracy changes regularly, and when it is low or unreliable, I get results similar to yours.

+2
source

All Articles