Calibration procedure for the MPU9250's accelerometer, gyroscope, and magnetometer using Python and a Raspberry Pi Computer.
Full tutorials at the following links:
- Calibration of an Inertial Measurement Unit (IMU) with Raspberry Pi - Part I
- Gyroscope and Accelerometer Calibration with Raspberry Pi
- Calibration of a Magnetometer with Raspberry Pi
Power is supplied to the MPU9250 via the 3.3V/GND pins on the Raspberry Pi computer. The MPU9250 board communicates with the RPi over its Inter-Integrated Circuit (I2C) pins, labeled SDA/SCL on both the RPi and MPU9265 boards. On the RPi, SDA is located on hardware pin 3, and SCL is located on hardware pin 5.
Install the following Python packages onto the Raspberry Pi:
pi@raspberrypi~ $ sudo pip3 install scipy matplotlib numpy
pi@raspberrypi~ $ sudo apt-get install libatlas-base-dev
Upon successful of the library installs above, download the mpu9250_i2c.py (the main backend for reading the MPU9250) from the repository along with the imu_test.py code.
- Run the imu_test.py
Verify that the 9 variables are being outputted similar to the screenshot below:
The calibration procedure uses a uniform cube to calibrate each sensor on the IMU (accel, gyro, mag). There are different procedures involved in calibrating each sensor, which can be broken down as follows:
- Gyroscope: calibrate under steady conditions
- Accelerometer: calibrate under graviation for each axis
- Magnetometer: calibrate under 360 degree rotation for each axis
Keeping in mind the coordinate reference for the MPU9250:
The plot below is an example output of the following script:
- mpu9250_full_calibration.py
The plot below is an example output of the following script:
- gyroscope_calibration.py
The plot below is an example output of the following script:
- accel_calibration.py
The plot below is an example output of the following script:
- accel_integration.py
The plot below is an example output of the following script:
- mag_hard_calibration.py