Disable LSM6DSL/DSO/DS3 on-chip gyro high-pass filter - #12026
sensei-hacker wants to merge 3 commits into
Conversation
The legacy LSM6DXX config path enabled the gyro's on-chip HPF at its slowest (16mHz) cutoff. That filter has a ~10s RC time constant, so its output keeps settling for ~20-30s after every power-on - well past INAV's ~2s startup gyro calibration window. The result is a real step in the raw gyro reading after calibration has already locked in a zero, which the AHRS reads as several seconds of attitude drift after boot. INAV already zeroes gyro bias in software, making the on-chip HPF redundant, and no other accgyro driver in the tree enables one.
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoDisable legacy LSM6DXX gyro high-pass filter
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can choose which labels appear on a finding, and whether they show icons or text |
|
Test firmware build ready — commit Download firmware for PR #12026 245 targets built. Find your board's
|
|
RAM / Flash usage vs. base commit
See RAM/flash optimization guide for techniques to reduce usage. |
Summary
Fixes a reported post-boot attitude drift on LSM6DSL-based boards: roll/pitch start level then drift to a plateau over ~10-20s after power-on.
Root Cause
lsm6dxxConfig()(the legacy config path used by LSM6DSL/LSM6DSO/LSM6DS3, as opposed to the newer "Gen V" LSM6DSV16X/LSM6DSK320X path) enabled the gyro's on-chip high-pass filter at its slowest available cutoff (16mHz). That filter has an RC time constant of ~10s, so the chip's own reported output keeps settling for ~20-30s after every power-on/reset — well past INAV's ~2s startup gyro calibration window (CALIBRATING_GYRO_TIME_MS). The result is a real step in the raw gyro reading after calibration has already locked in a zero offset, which the AHRS reads as attitude drift.This reproduced identically across three different physical IMU chip swaps on the reporter's board, which pointed away from a hardware defect and toward firmware/driver behavior. No other accgyro driver in the codebase enables an on-chip gyro HPF, and it's redundant since INAV already zeroes gyro bias in software.
Changes
src/main/drivers/accgyro/accgyro_lsm6dxx.c: write 0 to CTRL7_G's HPF-enable bits instead of enabling the on-chip HPF, in the legacy (non-Gen-V) chip config path.src/test/unit/accgyro_lsm6dxx_unittest.cc(new): regression test driving the reallsm6dGyroDetect()→gyro.initFn()→lsm6dxxConfig()path against a faked register-map "chip," asserting the on-chip HPF is never enabled, for both LSM6DSL and LSM6DSO chip IDs.src/test/unit/CMakeLists.txt: wire in the new test.Testing
USE_IMU_LSM6DXX(DAKEFPVF405), no new warnings.MSP_RAW_IMUlogging that originally showed the raw gyro X step at ~10-20s, to confirm the step is gone. Marking "Testing Required" until that comes back.