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.