Link Search Menu Expand Document

Calibrate IMU

Included in the voxl-imu-server package are two tools for calibrating the two IMUs on VOXL and any auxiliary IMUs connected to an external SPI bus.

Calibration data is saved to /data/modalai/ alongside all other calibration files.

Table of contents

  1. Temperature Calibration (OPTIONAL)
  2. Standard 6DOF Calibration
  3. Source

Temperature Calibration (OPTIONAL)

This is an optional calibration step that can improve performance. You can skip to Standard 6DOF Calibration below if you want to skip this.

This calibration uses the CPU to heat up the IMUs, then measures and records a quadratic model of the IMU temperature drift per axis. We recommend doing this with VOXL mounted in the drone and oriented in a normal flight orientation since temperature gradients and stress on the PCB will effect these results.

The process is slow and boring, it should take 2-4 minutes. The on-screen instructions are fairly self explanatory so we simple paste them here for reference:

Step 1 Cold Stage

voxl2:/$ voxl-calibrate-imu-temp
Server has IMU0 enabled and available for temperature calibration
WARNING, voxl-fan utility missing, can't turn on fan

We're now starting the COLD stage of the calibration.
Please stop all unnecessary services in another terminal, and try your best
to cool the PCB with a fan. Alternatively, start this process on a cold PCB.

We will be measuring the static gyro and accel offset as the board heats up.
VOXL must remain completely still through this entire process!
The IMU temperatures will be printed here continuously.

Press ENTER to start the heating process when you are happy that the IMUs
are cold enough for the lower bound. 25-35C is a reasonable goal for this.
CPU: 35.1C   IMU0: 29.6C

Step 2 Start Hot stage

We're now starting the HOT stage of the calibration. We just turned off
the fan, and started stressing the CPU to heat up the PCB.
This will run automatically for a while collecting data points until enough
data has been collected, something gets too hot, or the timeout is reached.
CPU: 62.9C   IMU0: 45.8C

Step 3 Wait for Hot stage to finish

CPU: 76.4C   IMU0: 53.0C   IMU1: 46.1C   taking sample #2
CPU: 86.7C   IMU0: 59.5C   IMU1: 53.2C   taking sample #3
CPU: 93.2C   IMU0: 66.0C   IMU1: 59.5C   taking sample #4
CPU: 94.8C   IMU0: 72.5C   IMU1: 66.6C   taking sample #5
CPU: 94.4C   IMU0: 75.1C   IMU1: 69.1C   IMU0 hit temp limit, finishing test
taking sample #6

Step 4 Results


Successfully wrote calibration to disk
voxl-imu-server should reload the new calibration automatically.
You can now run voxl-inspect-imu to check that the new data looks good

Now is probably a good time to run the normal voxl-calibrate-imu
calibration routine since the IMUs should both be up to temperature.

Standard 6DOF Calibration

This is a multi-step process that will walk you through doing a static offset calibration for the gyroscope followed by a 6DOF calibration for the accelerometer. This is very similar to the gyro and accelerometer calibration procedure for PX4 in QGroundControl.

It will also save the average IMU temperatures as part of this process which will be used in conjunction with the optional temperature calibration results if that is done in addition to this static calibration routine. In either case, we recommend performing this calibration with a warmed up VOXL board. If you intend to do the temperature calibration routine, it may be a good idea to do that FIRST since it will heat the board up. Then come back and do this static calibration after.

Note that starting the calibration routine will put the IMU server into calibration mode which causes it to output raw unrotated data from the IMUs, this will most likely cause any background VIO service to fail. After calibration is complete, the server will automatically load in the new calibration data and resume publishing corrected and rotated IMU values without needing to be restarted!

Step 1

ADB or SSH into VOXL. We recommend doing this wirelessly over SSH to allow more mobility when moving the drone around.

Step 2

(Optional) make sure voxl-imu-server is running

voxl2:/$ voxl-inspect-services
 Service Name          |  Enabled  |   Running   |  CPU Usage
 voxl-imu-server       |  Enabled  |   Running   |     1.8

Step 3

Launch the voxl-calibrate-imu utility and check that it detected all IMUs (“IMU0” and “IMU1” on VOXL and VOXL Flight, just “IMU0” on VOXL 2, and any external IMU’s you may have attached). Then press ENTER. Make sure the drone is upright in a normal flight orientation and is perfectly still! If you have a fan connected to the VOXL fan header, it should have stopped automatically at this point to reduce vibration.

voxl2:/$ voxl-calibrate-imu
Server has IMU0 enabled and available for calibration

We're about to start calibrating the gyro, make sure VOXL is
COMPLETELY STILL and press ENTER to start.

Step 4

After 1 second the results of the static gyroscope should print, for every IMU connected:

imu0 gyro offset (rad/s): -0.0115 -0.0130  0.0101
imu0 gyro baseline temp (C):   61.30

Step 5

Now we are going to perform the 6DOF accelerometer calibration. This involves placing the drone perfectly still in 6 roughly orthogonal orientations such that the offset and scale of all 3 axis can be measured.

The 6 orientations do not have to be perfectly aligned with gravity or perfectly orthogonal to each other. This calibration is not going to treat each axis individually and assume the accelerometer is experiencing exactly 1G in each orientation. Instead it takes all 6 points and fits an ellipsoid to the data. The centroid and size of this ellipsoid defines the accelerometer offset and scale.

That being said, IMUs are not perfectly linear and orienting the drone such that each axis aligns within about 10 degrees of gravity will help exercise the full range of the sensor and give the best results.

We're about to start calibrating the accelerometer.
This process will require you to orient the VOXL board in six roughly
orthogonal orientations. Ideally this should be with the six sides of
the board facing down. Try to do this without touching the board.

When you are ready to collect data for orientation 1 of 6,
press ENTER to start or Ctrl-C to quit

Step 6

Now go through the remaining 5 orientations. The exact order does not matter, just be sure to keep track and don’t double up or the process will fail!

Here is a visualization of the different orientations needed:

calibration orientations

accl0 offsets (m/s2):   0.0118 -0.0010  0.1146
accl0 scales        :   1.0017  1.0011  1.0010
accl0 baseline temp:   47.57C
accl1 offsets (m/s2):  -0.0958 -0.0903  0.0205
accl1 scales        :   1.0015  1.0005  1.0026
accl1 baseline temp:   42.95C

Successfully wrote calibration to disk
voxl-imu-server should reload the new calibration automatically.
You can now run voxl-inspect-imu to check that the new data looks good
You can also optionally run voxl-calibrate-imu-temp to run a more
involved temperature calibration.

Step 7

If the calibration was successful, the results should now be saved to /data/modalai/ and voxl-imu-server should have reloaded the new data.


The code is available on Gitlab