IMU processing (part 1)

A project log for Build your own TurtleBot 3 backbone

Implement the fantastic robotic packages offered by the TurtleBot3 robot on a budget without sacrificing features and performances.

matopmatop 08/12/2019 at 17:382 Comments

Hardware integration

IMU used for this project is the MiniIMU-v2 from Pololu, it incorporates several chips that offers 9 degrees of freedom, allowing a complete attitude estimation.

In order to passively filter noise from mechanical structure especially from motors, the IMU should be soft mounted. It is also possible to use integrated filters provided by the chip, all information regarding available filtering frequency and settings are available in the datasheets.

Attitude algorithm

The algorithm used on the OpenCR firmware is the Madgwick complementary filter. This filter produces good results regarding advanced sensor fusion algorithms (like Kalman filters), and is able to produce complete orientation (yaw, pitch and roll), when using magnetometer (it is not the case on the current OpenCR firmware).

I also use this algorithm for this projects with some improvements:

Sensors calibration


An automatic bias computing is performed at firmware startup, no immobility check are done doing this process, so robot should absolutely be kept static during this period!

Biases evolve in regard of temperature and mechanical stress on the board, although their computing during robot operation is not mandatory.


Madgwick filter uses accelerometer to compute gyroscopes biases. In details, each time acceleration norm equals to gravity (the robot's speed regarding terrestrial reference frame is constant), so if accelerometer have biases this condition never appends and gyroscope estimated rates diverge from real rates.

The selected method is the 6-point tumble sensor calibration, which use a quite simple sensor model, with scale factor, cross-coupling and offsets. All details can be found on this document from STMicroelectronics.

This calibration must be done after fixing the IMU on its support, because fixing it causes mechanical stress on the PCB which must be calibrated. Its not mandatory to realize systematically this calibration at startup, calibration data could be stored in memory.


The selected method consists in measuring scale factors and offsets which  correspond to hard iron distortions. More details and code are available at this really well made github page from kriswiner.

This calibration must be done after fixing the IMU on its support and after inserting it inside the robot frame because all magnetic components such as metallic frame or other electronics components could modify the sensor behavior (hard iron). As for magnetometers, this calibration could be done not systematically.

Development and results

Magnetometer calibration could be easily implemented as explained in kriswiner's document.

The rotation process requires to rotate IMU around its three axis, for now result is given through the arduino console and needs further development to be integrated with ROS (it might already exist package to calibrate IMU that could be used).

After realizing several calibrations on the same magneto, converging results tend to indicated that process is OK.

Accelerometer calibration using 6 points calibrations method doesn't offer such good results. 

First the method requires least square regression to obtain calibration matrix coefficients, altough this problem may have been already tackle with embedded software constrains, it still represent significant development effort.

Second,  this algo relies on the strong assumption that each measured point correspond to an axis oriented strictly colinear to gravity (ie equal to -g or g). Altgough a speficic cubic part has been designed, the mechanical tolerance can't guarantee that assumption.


Humpelstilzchen wrote 11/03/2019 at 19:55 point

Nice research. I never got a good algorithm to run on the AltIMU-v2 that runs as good as a BNO055. 

Do you have a comparison with the implementation by imu_complementary_filter as used by e.g.

  Are you sure? yes | no

matop wrote 11/16/2019 at 07:52 point

I didn't know this algorithm, it seems to perform well as it uncorrelates roll/pitch from yaw estimation (based on magneto). If you are interested, this algo and Madgwick filter are compared here:

It would be really interesting to compare hardware as well

  Are you sure? yes | no