-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Plane: Fixed formulas for load factor and roll, also corrected _TASmin in AP_TECS accordingly #29101
Open
IamPete1
wants to merge
2
commits into
ArduPilot:master
Choose a base branch
from
IamPete1:loadFactorFix
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.
+10
−7
Open
Plane: Fixed formulas for load factor and roll, also corrected _TASmin in AP_TECS accordingly #29101
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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 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 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
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.
This doesn't look NFC to me.
Previously
aerodynamic_load_factor
andmax_load_factor
were comparable quantities:But now
max_load_factor
is applied a square root, whereasaerodynamic_load_factor
is raised to ^2.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.
I think your right, here is some working out If we concentrate on just the squaring and ignore the rest
Existing code:
That makes the comparison:
Which we can re-write as
Then we square it:
The new equality is:
The difference is:
So as you say the equality is not the same. I guess the next question is which is the correct value. I will have to do some more reading I think.
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.
These changes are definitely functional! The old code wasn't typically off by much because these values are often close to 1, and most users are probably running very conservative AIRSPEED_MIN values, but the formulas are currently wrong.
This PR changes them to the canonical formulas based on well-established aeronautical principles:
For example, if the aircraft is flying at 20% over its stall/min speed, the old code would underestimate the roll limit by nearly 30%.
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.
@Georacer @rubenp02, I decided to just plot both, this is the python:
It results in:
So no change in behaviour. Did I make a mistake in my python?
At least I suspect the code is more complex than it needs to be. I don't know why we don't just calculate the max bank angle and constrain it, the result is the same. EG:
Then the aero load factor is not needed at all for this calculation.
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.
That's my bad, sorry, I completely forgot that it wasn't only the roll limit formula that was wrong but also the max. load factor one that it depends on. Since we're incorrectly squaring the max. load factor and then taking the square root, both mistakes cancel out. However, this PR is still a functional change because of the TECS side of things:
As for the attitude side of things, I still think it's better to have the correct formulas even if the calculations end up being correct with the wrong ones. For better maintainability and also in case that any of these values ever gets added to the flight logs (which could be useful).
Finally, the branching based on the aerodynamic load factor is unnecessary, but personally I think that it makes the code ever so slightly more clear. It makes it obvious that most of the time the roll isn't limited beyond the standard parameter limits.
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.
@rubenp02 you have the new load factor calculation with the old method in TECS. As they are in this PR there is no change in behaviour because TECS is also updated. Your
calculate_tecs_limits
should be this:So, I still think there is no change in behaviour as a result of this PR as it currently is. @Georacer @rubenp02 do you agree?
Of course there is a discussion to be had if we want to change the behaviour, but that can be a future PR.
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.
My bad again, you're right, this is NFC.
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.
@IamPete1 @rubenp02 sorry for the slow replies, it's been a little busy.
I'll try to reply when I can, but mind you I haven't blocked this PR.