Lying on a table without a move and connected with Qwiic cable to a raspberrypi (using I2C with IMU being the 0x69 I2C slave): I should get Ax=0, Ay=0, Az=1, Wx=0, Wy=0, Wz=0.
The only value whihc is close to expected is Az (16068 is close to 16384 = Accel_sensitivity <=> 16384 = 1g). All other values are unexpected and not even to what they should be?!..
The rate gyro needs to be calibrated, at least to remove the offsets. Most people just add up a few hundred readings while the sensor is stationary, and subtract the average values (one for each axis) from subsequent readings.
Pay attention to signed versus unsigned integers! This is a small negative value:
Thanks for this useful hint. You mean that I have to substract XA_OFFS (built from XA_OFFS_H and XA_OFFS_L) from ACCEL_XOUT, and, to substract XG_OFFS_USR (built from XG_OFFS_USRH and XG_OFFS_USRH) from GYRO_XOUT? Did I get your remark right?
Not sure how to remove the offset neither if XA_OFFS_* and XG_OFFS_USR* should be used and how… Can you detail on this?
Most people just add up a few hundred readings while the sensor is stationary, and subtract the average values
Or did you mean, I am supposed to average values coming out from the accelerometers / gyroscopes, average it, and substarct the mean from upcoming measurements ?..
Pay attention to signed versus unsigned integers
Also here not sure to fully understand. Can you precise what’s wring in the code? how to get the correct value?
But, I have still crazy values for gyroscopes?!.. The scale is +/- 250 dps and the IMU is at rest on the table: should get wx=wy=wz=0!
The raw data type from the sensor is signed integer. Your code is treating the data as unsigned integers.
This should be fixed now.
Can you detail this? Should I:
“just” add up a few hundred readings while the sensor is stationary, and subtract the average values (one for each axis) from subsequent readings?
use magneto to calibrate the gyro too?
add or substract XG_OFFS_USR (built from XG_OFFS_USRH and XG_OFFS_USRH) from GYRO_XOUT? (feel like it’s related to calibration - but no idea how/when/why to use this)
After a second read, my understanding is that the “Least Squares Ellipsoid Specific Fitting” algorithm from Li, use in Magneto, can calibrate magnetometer and accelerometer but not gyroscopes: is this correct?
AFAIU, on one side, the Li algorithm corrects non-orthogonality (of the 3 sensible axis), scale (magnitude) and bias (offset), and, on the other side, all sensors (magnetometer, accelerometer and gyroscopes) suffer from these problems… So I didn’t really get why gyroscopes seemed to be “only” offset corrected: if you know why, I’d be glad to know.
In 9DOF AHRS fusion algorithms, the accelerometer and magnetometer define the transformation between the body and fixed frames of reference, by defining Up and North.
The rate gyroscope is primarily used to temporarily correct the errors introduced by the assumption that the accelerometer defines “Up” when the sensor is rotating. Consequently, the rate gyro has no influence if the sensor is not rotating.
In practice, the rate gyro scale factors are orders of magnitude less critical than the offsets and so the errors in the scale factors can usually be ignored.