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
Refactor imuCalcKpGain #12859
Refactor imuCalcKpGain #12859
Conversation
Rewrite of old code, shall be functionally identical. Timer wraparound bugs fixed. Both original and new version do not match function comments, another change is necessary.
Do you want to test this code? You can flash it directly from Betaflight Configurator:
WARNING: It may be unstable. Use only for testing! |
@ctzsnooze : Refactored the code instead of trying to fix it. Can you test it, please? |
Actually, there is change: low gain is used during quiet phase |
AUTOMERGE: (FAIL)
|
stQuiet, | ||
stReset, | ||
stDisarmed | ||
} arState = stDisarmed; |
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.
does arState
mean attitudeResetState
?
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.
Yes. I don't like too long names when variable score is so small.. Maybe only 'state' will be less confusing
Thank you very much for this, it's a very nice re-factoring. I'll test it independently of the GPS changes, with a specific debug to look at the returned dcmKp value, as soon as I can. |
Hi @ledvinap This is an image showing values during the boot phase, with The debug is logging Initial This image shows a GPS Rescue failsafe initiation "too close to home", which results in an immediate disarm. There is the same brief 500ms period where This image shows a simple power-up, arm, disarm sequence. On disarming, after being armed, the IMU gain goes up to 25 (100x normal) for 500ms, then stays at 2.5 (10x normal). If the quad is stationary on the ground, I guess this is good, but I don't know for sure that it's so good if the disarm was mid-air in the event of a crash. This confirms that refactoring in this PR is working as intended, and that's excellent. Now the only question is whether these various boosts and timings are appropriate. I personally lack enough understanding of the IMU code to answer that question. I imagine that a 100x boost above normal Also, for what it's worth, I typically plug my battery in while holding the quad in my hand (most of mine are battery-below designs). We would then get the 100x Anyhow, I will approve the PR because the code works perfectly! Thank you! |
@ledvinap this PR is ready to be merged, I think, unless you feel that the functional behaviour should be changed, and want to include those changes in this PR. If you have no strong feelings about making functional changes to the Please let us know what you think? |
Rewrite of old code, shall be functionally identical. Timer wraparound bugs fixed. Both original and new version do not match function comments, another change is necessary. Co-authored-by: Petr Ledvina <ledvinap@hp124.ekotip.cz>
Rewrite of old code, shall be functionally identical. Timer wraparound bugs fixed. Both original and new version do not match function comments, another change is necessary. Co-authored-by: Petr Ledvina <ledvinap@hp124.ekotip.cz>
Rewrite of old code, shall be functionally identical. Timer wraparound bugs fixed. Both original and new version do not match function comments, another change is necessary. Co-authored-by: Petr Ledvina <ledvinap@hp124.ekotip.cz>
Rewrite of old code, shall be functionally identical. Timer wraparound bugs fixed. Both original and new version do not match function comments, another change is necessary. Co-authored-by: Petr Ledvina <ledvinap@hp124.ekotip.cz>
Rewrite of old code, shall be functionally identical. Timer wraparound bugs fixed.
Both original and new version do not match function comments, another change is necessary.