-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Smooth throttle in navigation modes on FW #6104
Smooth throttle in navigation modes on FW #6104
Conversation
Perfect, exactly what I had in mind. Thanks! |
I think you are not supposed to change |
I'm not so sure. I think the auto generated note is actually a note for the table on the web page Settings.md: I could be wrong though. |
@digitalentity What do you think of this pull request? Anything else I need to add before it can be merged? |
I have just build and flashed this for testing on my Dart 250. I will try to fly it later today and let you know how it went. Looks promising. |
I tested this with I have to say that I did get some substantial horizon drift and the OSD altitude fluctuated by +-20 meters when turning the nose or tail into the wind direction. I think it's unlikely that this is related to this PR but I want to mention it anyway for completeness. |
This PR calms down the throttle behavior around zero degrees pitch, but outside of ± Would it be difficult to apply a filter to the pitch angle to smooth out the throttle behavior for all pitch angles? I think a simple moving average would do, but this firmware already includes some way more advanced filters so there may be better options. I think this would be a more elegant solution. |
@avS2 - Interesting idea. Let's say we have 50% cruise throttle. I'm thinking that at 5 degrees filtered (or projected) ascent you would like the deadband to be centered around 55% and at 45% for a 5 degrees descent. Let me see what I can come up with. |
@Airwide Hmm, so you're saying to keep the throttle constant at |
@avS2 You're right, using the target angle would cause weird throttling in the target transitions. A moving average (or filtered) angle throttle compensation would work much better. |
Ok, I have added I thought it was unnecessary to create a cli variable for @avS2, @digitalentity WDYT? |
Nice! I have added some comments to the code. Have you tested this already? For testing purposes it would be nice to have a CLI command so that you can quickly turn the smoothing on and off in the field. |
I have not had the opportunity to test. My AR Wing crashed a couple of weeks ago, caused by the FrSky failsafe bug disarming the wing mid flight. Hopefully I will be up in the air again in the upcoming weeks. |
This pull request resolves issue #6073. This commit has two new variables UsageLatest commit has 2 new variables: 1. nav_fw_pitch2thr_smoothingThis variable holds the number of fixedWingPitchToThrottleCorrection cycles used to calculate a moving average for the pitch angle which is used for the pitch to throttle correction. Set
2. nav_fw_pitch2thr_thresholdThis variable creates a deadband of +/-
TestingI'm currently grounded, and haven't been able to test this latest commit. I should be up in the air in the next week or so. Meanwhile, help with testing and feedback would be much appreciated. Let me know if you have questions. |
@Airwide you are refering to centidegrees (1 degree = 100 centidegrees), however I guess you meant decidegrees (1degree = 10 decidegrees) |
This PR has been changed after feedback from @digitalentity.
@digitalentity , @avsaase , @kniuk , @b14ckyy WDYT? I plan to head out and test tomorrow, if the weather is ok. |
Awesome! I think this way of filtering the pitch angle is better, and the configuration much easier. I do wonder if we still need the threshold and if we can't just apply the filter to all pitch angles. As long as filteredPitch is not too sluggish and cruise throttle is set at a safe level I don't think that will ever cause problems. The threshold also causes a weird kink in the throttle response when climbing or diving at an angling outside of the threshold, for example clinbing at 10 degrees when This plot still uses averagePitch instead of filteredPitch, but I think the results would be similar. As filteredPitch is catching up to pitch, the difference becomes smaller than the threshold so there is an abrupt changes to using filteredPitch instead of pitch for the throttle correction calculation. Since filteredPitch has not yet fully caught there is a drop in the throttle output. I think any use of an if statement will always cause some sort of kink in the throttle response so I propose to just get rid of it. If @digitalentity doesn't want that an alternative would be to increase the max value for Weather permitting I will test this weekend. What would be a good starting point for PS.: GitHub indicates some line changes, but all that is different is the line ending? |
@avsaase I'm aware of the weird kink, and that's the reason why I implemented it the way I did in the first place with partial compensation outside the deadband. However, I think @digitalentity has a valid point about full compensation to avoid the risk of stalls. Let's try this version and see if the kink is a problem in reality. Interesting that you are thinking about a not too sluggish filter. I'm thinking the other way around to get a really stable throttle. In fact, I'm not sure I could increase WDYT? Btw, I went out for testing yesterday. Both my Dart 250 and my Mini Talon sky rocketed at the start of the test mission, so I had to abort the testing. I found out later that I had a 0 too many in the altitude value for all the waypoints. 👎 I will head out again as soon as the weather permits. |
Sorry about that. I have automatic removal of line end whitespace at save in one of my code editors. |
@Airwide I am not too familiar with low-pass filters so I can't really comment on sensible cutoff frequencies. I think the slower the |
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.
Looks good! Did you have a chance to test it yet?
@digitalentity I did get one flight in yesterday with the Dart 250 before the rain. I used the following settings:
Throttle correction was smoothed a bit. Immediate full correction outside of deadband worked as expected. No signs of the "kink" during transitions by looking at the dvr footage. I'm going to push another commit with an increased span of cutoff frequency beyond 0.1 Hz and also open up My next opportunity for testing is Tuesday if I'm lucky. I plan to test with much more smoothing and hopefully both with the Dart250 and the Mini Talon. @kniuk, @b14ckyy - I could build hex files for you, if you are interested in helping out with testing. |
I'm going to merge this now. I think we can keep the settings as-is - setting |
@digitalentity I'm sorry, I just realized I did a mistake in the last commit. I accidentally changed Edit: Bug fix created. See #6292 |
Maybe we should have some documentation on this feature? In fact, when we find sensible values I think it should be considered to enable it by default (and/or add it to the configurator). There are already several features that make INAV fly better but are hidden in the CLI where most inexperienced users will never find them. In my opinion this shouldn't be one of them. |
Fix for control smoothness bug introduced in PR #6104
@avsaase Agreed! Let's try and find a good basic setup together and then change the default value in a separate PR. Btw, I did get a test flight in this morning with my Mini Talon. I must say it is working good.
Here are two screenshots showing the behaviour with pitch changes outside of the deadband. I want to test with an even lower frequency. It would also be interesting to combine these settings with some |
I finally found the time and the weather to test this, and works very good! My setting were:
This is with the implementation in RC3. Is that with the new smoothing curve? Not that it makes a big difference with these settings. I think these settings for |
@avsaase Yes, RC3 has the new smoothing curve.
Your suggestion for default values is quite conservative, which can be a good thing. However, I would consider @digitalentity WDYT? |
This pull request resolves issue #6073.
Usage
Set new cli variable
nav_fw_pitch2thr_threshold
to a value between 0 and 100 decidegrees. That equals 0 to 10 degrees. 0 is default and keeps current behaviour.The variable is also accessible in the OSD menu under features/navigation/fixed wing/.
Testing
You can see in the movies that the red throttle curve is more stable in the video with
nav_fw_pitch2thr_threshold = 30
than in the video withnav_fw_pitch2thr_threshold = 0
.nav_fw_pitch2thr_threshold = 0
:nav_fw_pitch2thr_threshold = 30
:Btw, the higher throttle and speed with
nav_fw_pitch2thr_threshold = 0
indicates to me that my board orientation is off by a degree or two.@avS2 - Can you verify this is what you requested?