BNO055 correct calibration + bypass Sensor fusion

Hi everyone, I've recently been using a BNO055 to extrapolate yaw, pitch, roll data. only that the BNO055 (used in many aerospace projects, but poorly documented) does not explain how to bypass the storage of the Restoreoffset to implement the sensor calibration data. I feel like something is escaping me and I find little or nothing tangible online. I would like a process to do a calibration just once and then not have to think about it anymore. and above all it stores data forever.

I initially tried doing the calibration via Restoreoffset.ino and using the data in this way to bypass the sensor autocalibration at startup:

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
#include <math.h>


// definition of the time constants for sampling and the gyroscope address: first external imu then internal imu
uint16_t BNO055_SAMPLERATE_DELAY_MS = 100;
float BNO055_SAMPLERATE_DELAY = 0.01;
Adafruit_BNO055 bno = Adafruit_BNO055(-1, 0x28, &Wire);

// Calibration data
int16_t accel_offset_x = -15; 
int16_t accel_offset_y = -34;
int16_t accel_offset_z = 10;
int16_t gyro_offset_x = -1;
int16_t gyro_offset_y = -1;
int16_t gyro_offset_z = 0;
int16_t mag_offset_x = -576;
int16_t mag_offset_y = 287;
int16_t mag_offset_z = -65;
int16_t accel_radius = 1000;
int16_t mag_radius = 589;


// initialization of the variables present in the code
float roll, pitch, yaw, roll_d, pitch_d, yaw_d; // direct measurement

void setup() {

  Serial.begin(115200);
  delay(1000);

  bno.begin(OPERATION_MODE_NDOF);

  // Set calibration data
  adafruit_bno055_offsets_t calibrationData;

  calibrationData.accel_offset_x = accel_offset_x;
  calibrationData.accel_offset_y = accel_offset_y;
  calibrationData.accel_offset_z = accel_offset_z;

  calibrationData.gyro_offset_x = gyro_offset_x;
  calibrationData.gyro_offset_y = gyro_offset_y;
  calibrationData.gyro_offset_z = gyro_offset_z;

  calibrationData.mag_offset_x = mag_offset_x;
  calibrationData.mag_offset_y = mag_offset_y;
  calibrationData.mag_offset_z = mag_offset_z;

  calibrationData.accel_radius = accel_radius;
  calibrationData.mag_radius = mag_radius;

  bno.setSensorOffsets(calibrationData);


}

void loop() {


  
  // IMU DATA READING
  // angular position data acquisition
  imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);
  yaw = euler.x();
  roll = euler.y();
  pitch = -euler.z();

  // gyroscope data acquisition
  imu::Vector<3> gyro = bno.getVector(Adafruit_BNO055::VECTOR_GYROSCOPE);
  yaw_d = gyro.z();
  roll_d = gyro.y();
  pitch_d = gyro.x();

  // Print sensor data
  Serial.print("Roll: ");
  Serial.print(roll);
  Serial.print("\tPitch: ");
  Serial.print(pitch);
  Serial.print("\tYaw: ");
  Serial.println(yaw);

  Serial.print("Roll Rate: ");
  Serial.print(roll_d);
  Serial.print("\tPitch Rate: ");
  Serial.print(pitch_d);
  Serial.print("\tYaw Rate: ");
  Serial.println(yaw_d);

  delay(BNO055_SAMPLERATE_DELAY_MS);
}

But now I realize that it doesn't work for sure and it leaves me very disheartened. now I asked myself, if instead I use the raw data of the individual sensors without the integrated sensor fusion, and I use the data of the acc, gyro and mag inside a Madgwick filter or similar it should not cause problems. the point is how do I do the calibration? Could someone tell me very carefully (excusing my ignorance in advance) if there is a guide to achieve all this? some time ago I read about RTIMULib but I don't understand how to use it with the BNO055, nor how to calibrate the magnetometer (which in general I don't understand how to use outside of the Arduino IDE), I find in-depth documentation. I'm really asking for your desperate help.

Unfortunately, with the BNO055, you can't turn off the automatic calibration, and it doesn't work well.

You can certainly access the raw sensor data, calibrate the sensors and use another fusion algorithm (Mahony is my favorite), but there is not much point in doing that. The BNO055 is obsolete, and the current crop of 9DOF sensors outperforms it in every way, at less cost.

For gyro calibration, most people just calculate the offsets by collecting a few hundred points at startup, with the sensor held still, and average them. Subtract from subsequent readings.

The best overview of accelerometer and magnetometer calibration is this one: Tutorial: How to calibrate a compass (and accelerometer) with Arduino | Underwater Arduino Data Loggers

Which sensor would you recommend that is not too expensive, has an easy guide for complete calibration and is convenient for using the Mahory filter?

I don't know of an "easy guide" for 9DOF sensor calibration. Calibration requires several independent steps, and some technical skills.

This 9DOF sensor works as well as any I've used

A working Mahony filter for the ICM-20948 can be found here, with two calibration programs (one Python, one C) and instructions.

Magnetometer calibration example for a difficult case: https://forum.pololu.com/t/correcting-the-balboa-magnetometer/14315

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.