Files
ardupilot/libraries/AP_InertialSensor
Andy Piper 89253f2b9a AP_InertialSensor: keep the board rotation on the accel during gyro cal
_init_gyro() zeroed _board_orientation for the duration of the calibration
so the gyro samples came out in board frame, but that also stripped the
rotation from the accel. The last accel published in that window stays in
_accel[0], and AP_AHRS_DCM::reset() reads it a few lines later during
init_ardupilot(), gating only on the vector magnitude - so a board-frame
9.81 passes and DCM aligns to it. On a board mounted inverted that is 180
degrees out, and drift correction then takes minutes to walk it back,
failing the DCM attitude pre-arm throughout.

Skip the rotation in the gyro backend while _calibrating_gyro is set,
alongside the offset subtraction it already gates, and leave
_board_orientation alone. The accel is then never published in board frame
and DCM aligns level regardless of whether the value it reads is stale.
2026-08-19 21:30:55 +01:00
..