Code Monkey home page Code Monkey logo

mpu92-calibration's Introduction

MPU9250 Calibration using Python and a Raspberry Pi Computer

Calibration procedure for the MPU9250's accelerometer, gyroscope, and magnetometer using Python and a Raspberry Pi Computer.

Full tutorials at the following links:

- Wiring Diagram -

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. Wiring diagram of MPU9250 to RPI4


- Python Library Installs and IMU Tests -

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:

MPU9250 Test Printout


- Calibration Outline -

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:

MPU9250 Coordinate References


- Full Calibration and Real-Time Output -

The plot below is an example output of the following script:

  • mpu9250_full_calibration.py

MPU9250 Full Output


- Gyroscope Calibration Output -

The plot below is an example output of the following script:

  • gyroscope_calibration.py

MPU9250 Gyro Output


- Accelerometer Calibration Output -

The plot below is an example output of the following script:

  • accel_calibration.py

MPU9250 Accel Output


- Displacement Approximated from Accelerometer Double Integration -

The plot below is an example output of the following script:

  • accel_integration.py

MPU9250 Accel Output


- Magnetometer Hard Iron Offset -

The plot below is an example output of the following script:

  • mag_hard_calibration.py

MPU9250 Mag Output

mpu92-calibration's People

Contributors

josh-hrisko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mpu92-calibration's Issues

Acceleration Integration always shows same error

When running acc.'s integration script it always shows an error around 0.8m displacement in the y-axis, doesn't matter if I move it or not.
I commented mag's values because it makes rpi zero to work really slow and not sample fast enough, which results in error in the signal filtering later too.

I also load the calibration coeff's after the calibration is done.

the output:


Data Acquisition Stopped
1540 - number of samples
5 - seconds
308.0 - division (1540/5)
Sample Rate: 308Hz
Displace in y-dir: 0.90m

apply this lib

when I use GY-91 as imu , this github code can not be applied on this type of MPU9250
It will always pop out that GY-91 not wired correctly.
Is there anything wrong?

Error in Acceleration integration

I'm getting the following error after moving the IMU:


python3 accel_integration.py
Starting Data Acquisition
Start Moving IMU...
Data Acquisition Stopped
Traceback (most recent call last):
  File "accel_integration.py", line 189, in <module>
    imu_integrator()
  File "accel_integration.py", line 128, in imu_integrator
    b_filt,a_filt = signal.butter(4,5,'low',fs=Fs_approx)
  File "/home/pi/imu_project/venv/lib/python3.7/site-packages/scipy/signal/filter_design.py", line 2957, in butter
    output=output, ftype='butter', fs=fs)
  File "/home/pi/imu_project/venv/lib/python3.7/site-packages/scipy/signal/filter_design.py", line 2423, in iirfilter
    "must be 0 < Wn < fs/2 (fs={} -> fs/2={})".format(fs, fs/2))
ValueError: Digital filter critical frequencies must be 0 < Wn < fs/2 (fs=6.0 -> fs/2=3.0)

Any idea why this happens?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.