The situation:
I'm trying to create an indoor localisation system with the use of the magnetic field variations inside a building via fingerprinting. As a sensor I'm using my mobile phone a Galaxy Nexus.
Basically the idea to get my fingerprints is to measure the magnetic field in x,y and z direction respectively and rotate the vector by the orientation of the mobile to bring the vector into the world coordinate system. To locate someone he also measures the magnetic field, rotates the vector and send it to the server where I'll run my locating algorithms.
My problem:
When I measure the magnetic field at the same spot in different orientations I don't get the same result after rotating the vector. Even the field strength isn't the same.
To show this I have made four measurements at the same position and rotated the mobile around his z axis (standard Android specification) by 90, 180 and 270 degrees counter-clockwise respectively. Results can be seen on that 'table' and on the Matlab plots (follow link) below (if you want to have other views let me know)
Edit: To be more precise: What I really did was that I defined my own coordinate system called lets say the room coordinate system. I took one wall of the room and defined it as north. The y-axis of my phone aliens with that wall (at the first position) while it was flat on the table. Therefore the positive z-axis points to the sky and the x-axis is defined as the walls in 90 degrees. The vectors named with 'Raw' are the raw values of the phone and so they are in the coordinate system of the phone. The Vector named with 'Rotated' are rotated into that 'room coordinate system'. In the plot the dotted vectors are the raw vectors and the solid ones are the rotated ones.
╔═════════════╦════════╦════════╦════════╦══════════╗
║ 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 ║
╚═════════════╩════════╩════════╩════════╩══════════╝
As you can see even after rotating them they doesn't really match. Do you have any idea why this could be? Anything I might haven't considered yet? Thanks a lot in advance!
Edit2:
Second experiment
I did another experiment with way better results but still not as good as I expected. This time the direction is not as constant as it should be. This time I did my measurements outdoor. I aliened the y-axis to the true north an put it flat on the ground. I rotated it roughly 3 times 90 degrees counter-clockwise. I took with another camera a picture of the position of the mobile and measured the real rotation with photoshop. The results you can see on the table and on the plots 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 ║
╚═════════════╩════════╩════════╩════════╩══════════╝
Additional notes:
The values are averaged over a couple of seconds. So it's not a problem of noise.
I know I can't use the function getOrientation
because it uses the magnetic field to calculate the orientation and that wouldn't make sense since I want to find the variations of the magnetic field. For the example above I created the rotation quaternion manually.