I want to have a "compass heading" (I want to know the angle upon the north) using a magnetometer. I have seen on several tutorials that first, I need to calibrate it. When I looked up on how to do it I saw graphics comparisons of magnetometer value with and without calibration.
Here are the links I used : link_one and link_two
Both links shows that an uncalibrated magnetometer should display several clusters on the graph as bellow :
And calibrated mangnetometer should have both 3-axis on the same point around zero like this :
I am using the Adafruit LSM9DS1. I tried to get the same graphics with the following python code :
def save_mag_values():
f = open("magnetometer.csv","w")
for i in range(10000):
value = sensor.magnetic
f.write(",".join(map(str,value)))
f.write("\n")
Then I use the following gnuplot command to print :
gnuplot> plot "magnetometer.csv" using 1:2 title "XY" pointsize 2 pointtype 7, \
"magnetometer.csv" using 1:3 title "XZ" pointsize 2 pointtype 7, \
"magnetometer.csv" using 2:3 title "YZ" pointsize 2 pointtype 7
As it's written in the tutorial I just slowly move the sensor and after 1 min I print the values. Here is what I have for the uncalibrated magnetometer :
As you can see, the global shape is not a circle and I don't know why. I tried to calibrate it and here is what I have :
Can anyone tell me what I did wrong and why can't I have "circle shape" values like it should be ? Thanks
from Calibration of magnetometer doesn't give expected results
No comments:
Post a Comment