From 35f882cd3c8f010c56de3a4c656e37dc8bbae78e Mon Sep 17 00:00:00 2001 From: Jacob Dahl <37091262+dakejahl@users.noreply.github.com> Date: Thu, 25 Sep 2025 10:12:15 -0800 Subject: [PATCH] commander: accel cal rotate offsets and scales from body frame back into sensor frame before saving (#25626) - fixes https://github.com/PX4/PX4-Autopilot/issues/25606 --- src/modules/commander/accelerometer_calibration.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/modules/commander/accelerometer_calibration.cpp b/src/modules/commander/accelerometer_calibration.cpp index ba8bc59b3e..13990e01c9 100644 --- a/src/modules/commander/accelerometer_calibration.cpp +++ b/src/modules/commander/accelerometer_calibration.cpp @@ -366,17 +366,24 @@ int do_accel_calibration(orb_advert_t *mavlink_log_pub) const Matrix3f accel_T = mat_A.I() * CONSTANTS_ONE_G; // update calibration - worker_data.calibration[i].set_offset(offset); - worker_data.calibration[i].set_scale(accel_T.diag()); + const Dcmf &R = worker_data.calibration[i].rotation(); + + const Vector3f sensor_frame_offsets{R.transpose() *offset}; + const Matrix3f sensor_frame_scale{R.transpose() *accel_T * R}; + + worker_data.calibration[i].set_offset(sensor_frame_offsets); + worker_data.calibration[i].set_scale(sensor_frame_scale.diag()); #if defined(DEBUD_BUILD) PX4_INFO("accel %d: offset", i); - offset.print(); + sensor_frame_offsets.print(); PX4_INFO("accel %d: mat_A", i); mat_A.print(); PX4_INFO("accel %d: accel_T", i); accel_T.print(); + PX4_INFO("accel %d: scale matrix", i); + sensor_frame_scale.print(); #endif // DEBUD_BUILD worker_data.calibration[i].PrintStatus();