-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
EmuBoost2.0 (should perhaps have a different name) #670
Open
Quick-Flash
wants to merge
37
commits into
master
Choose a base branch
from
emuboost2
base: master
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.
Conversation
This file contains 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 filter is far more precise than the previous filter was. I've currently set this up with 36 bins (so accuracy is (max-min)/36 which for defaults is, 12.5hz, the old filter had a bin size of 16 which would have given an accuracy of 28.125hz, so this is over double as accurate.) This can also track up to 5 peaks and place 5 notch filters. It is also nicer on the cpu than the older version was, so all around really good. Using this filter + abg i was easily able to raise my gyro lpf filters to 300hz with dterm filters at around 150hz. I'm really excited to see what you all think about this filter :), P.S. all credit goes to @KarateBrot for coding this into betaflight, I may want to update this later to have dynamic widths and dynamic on the number of notches it uses, but so far, hey its awesome. Probably going to stay like this for 0.4.0. Only the defaults need testing right now.
as error is decreasing dterm will be boosted, while error is increasing dterm will be shrunk. The amount dterm is boosted or shrunk depends on how quickly error is increasing/decreasing. The faster it is changing the more we will boost/shrink d. As error transitions from growing to shrinking the dterm will go from being shrunk, back to normal strength, and then to boosted, then back to normal strength. Gain scheduling FTW :)
Changing sharpness in the osd to increment by 1 for Andrey
This reverts commit b4d0914.
This reverts commit e21315b.
@nerdCopter this should be tested |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
This code is best described as a form of smart error based gain scheduling. Essentially this code does 2 things, boost/shrink Dterm and boost Pterm. The logic here is simple. There are 2 ways to improve responsiveness on a PID controller. 1 is to use more Pterm, and another is to use less Dterm. Pterm is what drives your movement and Dterm is what slows your movement (at least dterm from gyro measurement, i've worked around this for dterm from error). So what if we want the best of both worlds when it comes to improving responsiveness while not gaining the problems associated with high Pterm and a low Dterm??? Well the logic here is simple, when we want/need more response boost the Pterm and shrink the Dterm. Shrinking the Dterm gives one major advantage over just increasing Pterm. Dterm is a source of noise, and shrinking the Dterm will help alleviate some of that noise and clean up our motors during moves.
How and when does it do this? Well the code looks at the change in error (the derivative of error) and the total error. The current error and the change in error are scaled between 1 and -1 before being multiplied together. This means that error has to be increasing or decreasing rapidly and error has to somewhat large for the full effect to occur.
Here is the math for how the Pterm is boosted and how the Dterm is boosted/shrunk along with some pseudo code. scaledError is our scaled total error and our scaled change in error.
pterm = pterm + pterm * (scaledError) * emuboost2; dterm = dterm * (1 - scaledError);
Pterm is only boosted when Dterm is shrunk, and Dterm can be both boosted or shrunk. In situations where the error is growing, Dterm will be shrunk. In situations where error is shrinking the Dterm is boosted to help deal with overshoot.
What the settings do and how to tune this.
How to tune this stuff: EmuBoost2 is relatively easy to tune. If you want more responsiveness increase the EmuBoost2 value, if it feels to responsive decrease this value. EmuBoost2_filter is a bit tougher to tune. A low filter cutoff will lead to a smoother boost, but at the downside of more delay in the boosting. Lower this filter if you have excess noise. EmuBoost2_cutoff essentially places how hard you need a move to be before you get much effect from EmuBoost2. Small cutoff values (10) means the effect is active almost all the time and a high cutoff (150+) will mean its mainly active during flips and rolls. EmuBoost2_expo is essentially how aggressively you want this effect to come into play. A high expo value will mean that small movements near center stick do not really feel "boosted" as much as a lower value. For expo play with small vs high values and see what feels best. If your cutoff is already quite small, then the effect of changing your expo will be less pronounced. It may be worthwhile to play with different values for your cutoff and expo and tune both together for the feel you desire.