v_1[3] corresponds to the item xy?
zhang12300 opened this issue · 5 comments
I amd phD candinate John. Recently I studied your code, and I found that there is some unconsistency between the description in https://teslabs.com/articles/magnetometer-calibration/ and your code .
In the decription, the fourth of the v_1, i.e., v_1[3] corresponds to the item yz. However, in your code, v_1[3] corresponds to the item xy. It confused me a lot. Hopefully you can check it and looking forward to receiving your reply soon. Thank you!
M = np.array([[v_1[0], v_1[3], v_1[4]],
[v_1[3], v_1[1], v_1[5]],
[v_1[4], v_1[5], v_1[2]]])
Hi,
Many thanks for the review. I have only copied the code from testlabs without deep analysis :(
I mean that the post from Robert R solve the question
I believe in your code example your M is incorrect. Based on your notation in your Quadric section you have [[a f g], [f b h], [g h c]] as your M matrix. A simple check here is that in the D matrix, your 5th element is your 2XY term. This term should go in the h positions as per [[a h g], [h b f], [g f c]], instead you have the XY term assigned in the f positions.
The overall result is that your A_1 matrix will have "mirrored" column 1 and row 1.
Interestingly enough, this flip doesn't seem to impact the calibration significantly.
There is a mistake !
I've juste changed of job and have no time anymore to solve that actually. Feel free to post a commit
Thank you
Hi, Many thanks for the review. I have only copied the code from testlabs without deep analysis :(
I mean that the post from Robert R solve the question
I believe in your code example your M is incorrect. Based on your notation in your Quadric section you have [[a f g], [f b h], [g h c]] as your M matrix. A simple check here is that in the D matrix, your 5th element is your 2XY term. This term should go in the h positions as per [[a h g], [h b f], [g f c]], instead you have the XY term assigned in the f positions. The overall result is that your A_1 matrix will have "mirrored" column 1 and row 1. Interestingly enough, this flip doesn't seem to impact the calibration significantly.
There is a mistake !
I've juste changed of job and have no time anymore to solve that actually. Feel free to post a commit
Thank you
Thank you for your patience!
Thank YOU for deep analysis !
I was only interested in magnetometers to build my weather station. I don't have your expertise in this area.
Perhaps could you correct the script for the hobbyist community ?
Thank you again for your very productive intervention.
However, I don't really understand why I had results that seemed correct. Maybe the Z factor has no influence in my horizontal system (weather vane). Glad if you explain me :)
The code is indeed broken on the Teslabs page and here. To fix it according to the comment by Robert R on the Teslabs page, use the following to define the M matrix.
# quadratic-form parameters (rearranged to correct f and h terms)
M = np.array([[v_1[0], v_1[5], v_1[4]],
[v_1[5], v_1[1], v_1[3]],
[v_1[4], v_1[3], v_1[2]]])
Complete, modified calibrate2.py
calibrate2.py.txt
I've tested this on a known example, using a complete 3D data set, as solved by a different procedure (C program magneto), and get the expected result. See https://forum.pololu.com/t/correcting-the-balboa-magnetometer/14315
Result:
Many thanks, commited.
Regards