bolderflight / invensense-imu

Arduino and CMake library for communicating with the InvenSense MPU-6500, MPU-9250 and MPU-9255 nine-axis IMUs.
MIT License
498 stars 211 forks source link

Magnetometer calibration breaks if biases and scales were set before #57

Closed dbuezas closed 3 years ago

dbuezas commented 5 years ago

During calibration, the samples from the magnetometer are corrected using the scales and biases already stored.

e.g.: line 897:

_hxfilt = (_hxfilt * ((float)_coeff - 1) + (getMagX_uT() / _hxs + _hxb)) / ((float)_coeff);

This results in the new biases implicitly being relative to the old ones (which breaks them). A way to test it is to calibrate twice on a row, which results in different values.

I think the same line should be:

_hxfilt = (_hxfilt * ((float)_coeff - 1) + getMagX_uT()) / ((float)_coeff);

instead.

Amazing lib btw :)

korbinianbauer commented 4 years ago

Any updates on this?

wlwatkins commented 3 years ago

I've looked at the code, trying to port it to golang, i don't see what _hxfilt, _hyfilt, _hzfilt are as they are not declared to a given value if i'm not mistake.

flybrianfly commented 3 years ago

Calibration functionality was removed from this library.