Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sfusion, BMI270] Perform gryo motionless calibration before gyro offset calibration #367

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/sensors/softfusion/drivers/bmi270.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
5 changes: 4 additions & 1 deletion src/sensors/softfusion/softfusionsensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down