diff --git a/src/sensors/softfusion/drivers/bmi270.h b/src/sensors/softfusion/drivers/bmi270.h index 1436d5dc..d122ce97 100644 --- a/src/sensors/softfusion/drivers/bmi270.h +++ b/src/sensors/softfusion/drivers/bmi270.h @@ -363,6 +363,11 @@ struct BMI270 { gyroSensitivity.z = crt_values[2]; } + // CRT seems to leave some state behind which isn't persisted after + // restart. If we continue without restarting, the gyroscope will behave + // differently on this run compared to subsequent restarts. + restartAndInit(); + setNormalConfig(gyroSensitivity); } diff --git a/src/sensors/softfusion/softfusionsensor.h b/src/sensors/softfusion/softfusionsensor.h index cb1709b8..133bea48 100644 --- a/src/sensors/softfusion/softfusionsensor.h +++ b/src/sensors/softfusion/softfusionsensor.h @@ -320,7 +320,6 @@ class SoftFusionSensor : public Sensor { if (calibrationType == 0) { // ALL calibrateSampleRate(); - calibrateGyroOffset(); if constexpr (HasMotionlessCalib) { typename imu::MotionlessCalibrationData calibData; m_sensor.motionlessCalibration(calibData); @@ -330,6 +329,10 @@ class SoftFusionSensor : public Sensor { sizeof(calibData) ); } + // Gryoscope offset calibration can only happen after any motionless + // gyroscope calibration, otherwise we are calculating the offset based + // on an incorrect starting point + calibrateGyroOffset(); calibrateAccel(); } else if (calibrationType == 1) { calibrateSampleRate();