bolderflight / invensense-imu

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

Calibration functions are no longer included as part of this library #83

Closed GiovanniCmpaner closed 3 years ago

GiovanniCmpaner commented 3 years ago

Calibration functions are no longer included as part of this library.

Originally posted by @flybrianfly in https://github.com/bolderflight/mpu9250-arduino/issues/78#issuecomment-778863376

So what are the alternatives for calibration?

flybrianfly commented 3 years ago

I would collect accelerometer and magnetometer data and use an offline tool, such as Octave, to estimate the bias and scale factors. Accelerometer and magnetometer calibration likely only needs to be performed once. For the gyro, I would collect a few seconds of data and compute the mean (i.e. the sensor bias). Gyro data is highly temperature dependent and likely does need to be performed each time the sensor is used.

Our issue with including calibration in the lib is:

  1. It added complexity to our library, when we would like to focus on simply interfacing with the sensor. Also considering that calibration will need to be applied to every IMU, it didn't make sense to recreate that for each IMU library we develop.
  2. The calibration process was confusing to our users, resulting in a lot of issues that were simply due to running the calibration processes incorrectly.
  3. A generic arduino library has to support a wide range of devices, from the Arduino Uno to a Teensy 4.1. For the magnetometer calibration, I would prefer to fit the data to a sphere using a least-squares fit, but that seemed outside of what we could code for an Uno. Ultimately, the best tools for the job are offline packages, especially since this process doesn't need to be performed often.