Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/michal34512/magnetometer-calibration
magnetometer calibration algorithm with light weight linear algebra library
https://github.com/michal34512/magnetometer-calibration
accelerometer calibraition eigen ellipsoid-fit imu least-squares light linear-algebra magnetometer
Last synced: 15 days ago
JSON representation
magnetometer calibration algorithm with light weight linear algebra library
- Host: GitHub
- URL: https://github.com/michal34512/magnetometer-calibration
- Owner: michal34512
- License: mit
- Created: 2024-06-28T21:48:02.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-08-20T15:21:42.000Z (5 months ago)
- Last Synced: 2024-08-20T17:38:09.512Z (5 months ago)
- Topics: accelerometer, calibraition, eigen, ellipsoid-fit, imu, least-squares, light, linear-algebra, magnetometer
- Language: C
- Homepage:
- Size: 43.9 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Magnetometer calibration
Magnetometer calibration algorithm using ellipsoid fit and least squares method with light weight linear algebra library. Unlike similar algorithms, it does not require external linear-algebra library thus it's perfect for:
- ESP32
- Arduino
- Lightweight applications
Visualization (graphs not included in the code)
# How to use
```c
// data arrays
double x[231] = {18.923634, 20.785405, 23.265396, ...};
double y[231] = {94.943907, 103.939205, 113.472091, ...};
double z[231] = {27.951207, 32.958822, 31.772349, ...};
// Create vector based on data arrays
Vector vx = vec_from_array(x, 231);
Vector vy = vec_from_array(y, 231);
Vector vz = vec_from_array(z, 231);
// Fit best ellipsoid to the data and save offest vector, translation matrix
Callibration_t calib = calib_calibrate_sensor(vx, vy, vz);
// Print the result
vec_print(calib.offset);
mat_print(calib.transform);
// Compensate new data point based on calib
// new data = calib.transform*(old data - calib.offset)
Vector new_data_vector = vec_new(3);
VEC_X(new_data_vector) = 18.923634;
VEC_Y(new_data_vector) = 94.943907;
VEC_Z(new_data_vector) = 27.951207;
calib_calibrate_point(calib, new_data_vector);
// Print calibrated vector
vec_print(new_data_vector);
```
# Algorithm perfomance
Average variance of points length in relation to calibration data noise (random mag. 100 data points):
![image](https://github.com/michal34512/Magnetometer-calibration/assets/136522993/df930068-2c8a-4ca8-b1ef-d4f1a6730eee)
Average chance of algorithm failure in relation to data point count (random mag. data with 10% noise):
![image](https://github.com/michal34512/Magnetometer-calibration/assets/136522993/df975675-cb75-4c7f-963d-f025fb2569e8)
Example of data calibration with 50% noise:
![image](https://github.com/michal34512/Magnetometer-calibration/assets/136522993/9752cadd-9f7c-496e-8559-d9e351b3e218)