-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Release/9.1 to maintenance-10.x #12005
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
Open
sensei-hacker
wants to merge
14
commits into
maintenance-10.x
Choose a base branch
from
release/9.1
base: maintenance-10.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+363
−36
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a246461
Update PR branch-suggestion workflow for the 10.x/11.x cycle
sensei-hacker f043c0b
Clarify the master-target note in the branch-suggestion comment
sensei-hacker df1a24b
Merge pull request #11989 from sensei-hacker/update-pr-branch-suggest…
sensei-hacker 863c2fa
docs: update pr-branch-suggestion README entry for 10.x/11.x cycle
sensei-hacker b41db7f
Merge pull request #11990 from sensei-hacker/update-pr-branch-suggest…
sensei-hacker f3c75c6
add link to https://inavflight.github.io
sensei-hacker 7cb12ea
Merge pull request #11991 from sensei-hacker/readme-update.md
sensei-hacker 50b1637
Disable LSM6DSL/DSO/DS3 on-chip gyro high-pass filter
sensei-hacker 3e689b5
Shorten CTRL7_G comment
sensei-hacker e08ddd6
Reword CTRL7_G comment
sensei-hacker 0251bb9
Merge pull request #12026 from sensei-hacker/lsm6dxx-gyro-hpf-settling
sensei-hacker 99e3918
GPS: keep the heartbeat across the driver solution copy
b14ckyy 1bf1f57
IMU: filter the TURNRATE GPS speed every loop again
b14ckyy a26e276
Merge pull request #12045 from sensei-hacker/fix-gps-heartbeat-9.1
sensei-hacker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,189 @@ | ||
| /* | ||
| * This file is part of INAV. | ||
| * | ||
| * INAV is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * INAV is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with INAV. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| // Regression test for the LSM6DSL/LSM6DSO/LSM6DS3 attitude-drift bug reported on Discord | ||
| // (custom STM32F405 + LSM6DSL board, INAV 9.1.0): roll/pitch drifted for ~10-20s after | ||
| // boot because lsm6dxxConfig() enabled the chip's on-chip gyro high-pass filter at its | ||
| // slowest (16mHz) cutoff, which has a ~10s RC time constant and keeps settling the raw | ||
| // gyro output for ~20-30s after every power-on/reset - well past INAV's ~2s startup | ||
| // gyro calibration window. This test drives the real, unmodified production entry point | ||
| // (lsm6dGyroDetect() -> gyro->initFn() -> lsm6dxxConfig()) against a fake register-map | ||
| // "chip" and asserts the byte actually written to CTRL7_G does not enable the on-chip HPF. | ||
|
|
||
| #include <cstring> | ||
| #include <cstdint> | ||
|
|
||
| extern "C" { | ||
| #include "platform.h" | ||
|
|
||
| #include "common/utils.h" | ||
| #include "drivers/time.h" | ||
| #include "drivers/resource.h" | ||
| #include "drivers/bus.h" | ||
| #include "drivers/accgyro/accgyro.h" | ||
| #include "drivers/accgyro/accgyro_mpu.h" | ||
| #include "drivers/accgyro/accgyro_lsm6dxx.h" | ||
| } | ||
|
|
||
| #include "gtest/gtest.h" | ||
|
|
||
| extern "C" { | ||
|
|
||
| bool lsm6dGyroDetect(gyroDev_t *gyro); | ||
|
|
||
| // --- Fake "chip": a plain byte-addressed register map, backing busRead()/busWrite() --- | ||
| static uint8_t fakeRegs[256]; | ||
| static busDevice_t fakeBusDevice; | ||
| static uint32_t fakeScratchpad[(BUS_SCRATCHPAD_MEMORY_SIZE + 3) / 4]; | ||
|
|
||
| busDevice_t * busDeviceInit(busType_e bus, devHardwareType_e hw, uint8_t tag, resourceOwner_e owner) | ||
| { | ||
| UNUSED(bus); UNUSED(hw); UNUSED(tag); UNUSED(owner); | ||
| return &fakeBusDevice; | ||
| } | ||
|
|
||
| busDevice_t * busDeviceOpen(busType_e bus, devHardwareType_e hw, uint8_t tag) | ||
| { | ||
| UNUSED(bus); UNUSED(hw); UNUSED(tag); | ||
| return &fakeBusDevice; | ||
| } | ||
|
|
||
| void busDeviceDeInit(busDevice_t *dev) | ||
| { | ||
| UNUSED(dev); | ||
| } | ||
|
|
||
| void * busDeviceGetScratchpadMemory(const busDevice_t *dev) | ||
| { | ||
| UNUSED(dev); | ||
| return fakeScratchpad; | ||
| } | ||
|
|
||
| void busSetSpeed(const busDevice_t *dev, busSpeed_e speed) | ||
| { | ||
| UNUSED(dev); UNUSED(speed); | ||
| } | ||
|
|
||
| bool busWrite(const busDevice_t *dev, uint8_t reg, uint8_t data) | ||
| { | ||
| UNUSED(dev); | ||
| fakeRegs[reg] = data; | ||
| return true; | ||
| } | ||
|
|
||
| bool busRead(const busDevice_t *dev, uint8_t reg, uint8_t *data) | ||
| { | ||
| UNUSED(dev); | ||
| *data = fakeRegs[reg]; | ||
| return true; | ||
| } | ||
|
|
||
| bool busWriteBuf(const busDevice_t *dev, uint8_t reg, const uint8_t *data, uint8_t length) | ||
| { | ||
| UNUSED(dev); | ||
| for (uint8_t i = 0; i < length; i++) { | ||
| fakeRegs[reg + i] = data[i]; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| bool busReadBuf(const busDevice_t *dev, uint8_t reg, uint8_t *data, uint8_t length) | ||
| { | ||
| UNUSED(dev); | ||
| for (uint8_t i = 0; i < length; i++) { | ||
| data[i] = fakeRegs[reg + i]; | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| void delay(timeMs_t ms) | ||
| { | ||
| UNUSED(ms); | ||
| } | ||
|
|
||
| void delayMicroseconds(timeUs_t us) | ||
| { | ||
| UNUSED(us); | ||
| } | ||
|
|
||
| // Real mpuChooseGyroConfig() only needs to pick a table row for boards sharing the MPU | ||
| // family; it's irrelevant to the CTRL7_G behavior under test, so return a fixed, valid | ||
| // config regardless of input. | ||
| const gyroFilterAndRateConfig_t * mpuChooseGyroConfig(uint8_t desiredLpf, uint16_t desiredRateHz) | ||
| { | ||
| UNUSED(desiredLpf); UNUSED(desiredRateHz); | ||
| static const gyroFilterAndRateConfig_t fakeConfig = { 0, 1000, { 0, 0 } }; | ||
| return &fakeConfig; | ||
| } | ||
|
|
||
| bool gyroCheckDataReady(gyroDev_t *gyro) | ||
| { | ||
| UNUSED(gyro); | ||
| return true; | ||
| } | ||
|
|
||
| } // extern "C" | ||
|
|
||
| class LSM6DxxConfigTest : public ::testing::Test { | ||
| protected: | ||
| void SetUp() override | ||
| { | ||
| memset(fakeRegs, 0, sizeof(fakeRegs)); | ||
| memset(&fakeBusDevice, 0, sizeof(fakeBusDevice)); | ||
| memset(&gyro, 0, sizeof(gyro)); | ||
| gyro.lpf = GYRO_HARDWARE_LPF_NORMAL; | ||
| gyro.requestedSampleIntervalUs = 1000; | ||
| } | ||
|
|
||
| gyroDev_t gyro; | ||
| }; | ||
|
|
||
| // Drives the real production path for the LSM6DSL chip (the exact chip reported in the | ||
| // bug: attitude drift over ~10-20s caused by raw gyro X stepping after calibration closed). | ||
| TEST_F(LSM6DxxConfigTest, LSM6DSLDoesNotEnableOnChipGyroHighPassFilter) | ||
| { | ||
| fakeRegs[LSM6DXX_REG_WHO_AM_I] = 0x6A; // LSM6DSL_CHIP_ID | ||
|
|
||
| ASSERT_TRUE(lsm6dGyroDetect(&gyro)); | ||
| ASSERT_NE(gyro.initFn, nullptr); | ||
|
|
||
| gyro.initFn(&gyro); // -> lsm6dxxSpiGyroInit() -> lsm6dxxConfig() | ||
|
|
||
| const uint8_t ctrl7g = fakeRegs[LSM6DXX_REG_CTRL7_G]; | ||
| EXPECT_EQ(ctrl7g & LSM6DXX_MASK_CTRL7_G, 0) | ||
| << "CTRL7_G HPF bits were written as 0x" << std::hex << (int)(ctrl7g & LSM6DXX_MASK_CTRL7_G) | ||
| << " - the on-chip gyro high-pass filter must stay disabled. Its slowest cutoff has a " | ||
| << "~10s RC time constant, so re-enabling it reproduces the reported ~10-20s attitude " | ||
| << "drift as the chip's own filter output keeps settling well past INAV's startup " | ||
| << "gyro calibration window."; | ||
| EXPECT_EQ(ctrl7g & LSM6DXX_VAL_CTRL7_G_HP_EN_G, 0) << "on-chip gyro HPF enable bit must not be set"; | ||
| } | ||
|
|
||
| // Same assertion for LSM6DSO, which shares lsm6dxxConfig()'s legacy (non-"Gen V") path. | ||
| TEST_F(LSM6DxxConfigTest, LSM6DSODoesNotEnableOnChipGyroHighPassFilter) | ||
| { | ||
| fakeRegs[LSM6DXX_REG_WHO_AM_I] = 0x6C; // LSM6DSO_CHIP_ID | ||
|
|
||
| ASSERT_TRUE(lsm6dGyroDetect(&gyro)); | ||
| ASSERT_NE(gyro.initFn, nullptr); | ||
|
|
||
| gyro.initFn(&gyro); | ||
|
|
||
| const uint8_t ctrl7g = fakeRegs[LSM6DXX_REG_CTRL7_G]; | ||
| EXPECT_EQ(ctrl7g & LSM6DXX_MASK_CTRL7_G, 0); | ||
| EXPECT_EQ(ctrl7g & LSM6DXX_VAL_CTRL7_G_HP_EN_G, 0); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2. Suggested 11.x changes lack nightly builds
🐞 Bug☼ ReliabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools