-
Notifications
You must be signed in to change notification settings - Fork 269
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
Lift Drag Bug Fix #2189
Lift Drag Bug Fix #2189
Conversation
Signed-off-by: frederik <[email protected]>
Signed-off-by: frederik <[email protected]>
Signed-off-by: frederik <[email protected]>
Signed-off-by: frederik <[email protected]>
Wind inclusion
Added in the wind velocity as a factor from the original liftdrag plugin. |
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.
Run make codecheck
.
See here: https://gazebosim.org/docs/harmonic/contributing
Remove trailing spaces as pointed out by the linter here: https://github.com/gazebosim/gz-sim/actions/runs/6396048528/job/17419401043?pr=2189
Signed-off-by: frederik <[email protected]>
…nt' into lift_drag_improvement
Signed-off-by: frederik <[email protected]>
Removed long lines and fixed trailing white spaces. |
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.
Currently this plugin causes a segfault in the tests - I think its because you access components without checking if they exist.
To test your plugin doesnt break current integration tests run the following steps:
colcon build
. install/setup.bash
- run
build/gz-sim7/bin/INTEGRATION_lift_drag_system
Signed-off-by: frederik <[email protected]>
Improved based on comments. Integration tests and codecheck both pass. Commented feedback needs a reply if possible. |
Signed-off-by: frederik <[email protected]>
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.
Thanks for iterating on this so quickly. LGTM!
Signed-off-by: Rhys Mainwaring <[email protected]>
@ahcorde, I did not spot this change before it was merged into Harmonic, but have now tested with some of the models set up for ArduPilot and have some questions: Sweep angle calculationI think the calculation for the sweep angle adjustment should not include the square root. In the original Gazebo classic version of the plugin the variable was named It was change to I cannot find the PR corresponding to the change, so it's not clear why it was renamed. The argument for using the square of the angle is that the sweep angle correction arises from using the velocity normal to the leading edge of the wing in the lift calculation, rather than the free stream velocity. As the velocity appears quadratically in the dynamic pressure the correction requires Unfortunately there is no reference provided to the source of the calculations used in the original derivation of the plugin, so it's hard to confirm the formula forming the basis for the calculations. Moment calculationThis calculation is not enabled in the Gazebo classic version: There is not much explanation aside from it not being checked. I think this term is supposed to account for the movement of the centre of pressure with velocity, and allows the lift and drag coefficients to be calculated and applied at the quarter chord point rather than the unknown centre of pressure (so the cp parameter might be better named quarter chord?). In any case there are a few models that will not work with this calculation enabled. The Zephyr is one of them: https://app.gazebosim.org/OpenRobotics/fuel/models/Zephyr%20Delta%20Wing. The solution to get this model working again is to zero An announcement that this change may break some models would be helpful. |
Hi Rhys,
Thanks for pointing that out. It seems my review fell short of certain
checks. I think it seems like this PR has introduced a regression. For
moment calculations, the easiest thing to solve the incompatibilities is to
default cma to zero. We can revert the change that added a regression to the cos term.
On another note perhaps we should not allow any changes into
existing plugins on the release branches. i,e A change like this should target `main` so that
errors get caught during the tutorial party.
…On Fri, Dec 22, 2023 at 12:16 AM Rhys Mainwaring ***@***.***> wrote:
@ahcorde <https://github.com/ahcorde>, I did not spot this change before
it was merged into Harmonic, but have now tested with some of the models
set up for ArduPilot and have some questions:
Sweep angle calculation
I think the calculation for the sweep angle adjustment should not include
the square root. In the original Gazebo classic version of the plugin the
variable was named cosSweepAngle2 (i.e. squared).
-
https://github.com/gazebosim/gazebo-classic/blob/7af0e34ff724b3447f85eba039f596cf6895aa8e/plugins/LiftDragPlugin.cc#L150C10-L150C24
It was change to cosSweepAngle in:
- ***@***.***
#diff-66d0f4a4af1ce5c7c5c7cffb63821f5a1aa944650b15be8e0ddcd44ee33e6603L167
<gazebosim/gazebo-classic@9b98cb3#diff-66d0f4a4af1ce5c7c5c7cffb63821f5a1aa944650b15be8e0ddcd44ee33e6603L167>
I cannot find the PR corresponding to the change, so it's not clear why it
was renamed.
The argument for using the square of the angle is that the sweep angle
correction arises from using the velocity normal to the leading edge of the
wing in the lift calculation, rather than the free stream velocity. As the
velocity appears quadratically in the dynamic pressure the correction
requires cos(sweep_angle)^2 not cos(sweep_angle). The adjustment is then
applied as a correction to the lift coefficient rather than the velocity
used in the dynamic pressure calculation which is possibly where the
confusion arises, as it appears that it's taking a component of the
resultant force, not the input velocity.
Unfortunately there is no reference provided to the source of the
calculations used in the original derivation of the plugin, so it's hard to
confirm the formula forming the basis for the calculations.
Moment calculation
This calculation is not enabled in the Gazebo classic version:
-
https://github.com/gazebosim/gazebo-classic/blob/7ccef40e24831eb5cd974b489ee279fc064eacc4/plugins/LiftDragPlugin.cc#L346
There is not much explanation aside from it not being checked. I think
this term is supposed to account for the movement of the centre of pressure
with velocity, and allows the lift and drag coefficients to be calculated
and applied at the quarter chord point rather than the unknown centre of
pressure (so the cp parameter might be better named quarter chord?).
In any case there are a few models that will not work with this
calculation enabled. The Zephyr is one of them:
https://app.gazebosim.org/OpenRobotics/fuel/models/Zephyr%20Delta%20Wing.
The solution to get this model working again is to zero <cma>0.0</cma> so
the adjustment is zero. It should not affect any PX4 mdoels as AFAICT they
all set the parameter to zero. The models used with ArduPilot are being
updated to also zero this adjustment (which is backwards compatible with
Garden).
An announcement that this change may break some models would be helpful.
—
Reply to this email directly, view it on GitHub
<#2189 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEEMQDC4ZX4XZ56HCGCKZDYKROFXAVCNFSM6AAAAAA5Q5WX4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRWGU4DSOJUGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Maybe, although in this case the changes looked reasonable because of the variable naming. Btw I'm still not 100% certain of the intended sweep angle calculation. If someone has a good reference that would settle it that would be great. From what I understand the original motivation for swept wings arose to reduce the effective stream velocity over the wings in transonic / supersonic flight (so argument for taking components of the velocity). Either way a comment above the calculation about the intention would make things clearer, and we could revert the variable name back to it's original
|
No I dont know about cos vs cos2 @frede791 is there a reason why you'd use cos over cos2 otherwise I'll revert that change. |
The changes in #2189 have caused a regression for our upstream users. This fix disables moment calculations by defaulting Cma to zero. It should help mitigate some of the regression. There is also an [ongoing discussion](#2189 (comment)) as to whether the cos term should be cos^2 or cos. Signed-off-by: Arjo Chakravarty <[email protected]>
You're right - I misread that. Thanks for the the PR defaulting |
Reference for simple sweep theory: https://web.archive.org/web/20060727083150/http://www.desktopaero.com/appliedaero/potential3d/sweeptheory.html Should relabel variable to |
In response to #2189 (comment) As suggested by @srmainwaring I also renamed cosSweepAngle -> cos2SweepAngle to prevent further confusion. Signed-off-by: Arjo Chakravarty <[email protected]>
* Default CMA in LiftDrag pluginto zero The changes in #2189 have caused a regression for our upstream users. This fix disables moment calculations by defaulting Cma to zero. It should help mitigate some of the regression. There is also an [ongoing discussion](#2189 (comment)) as to whether the cos term should be cos^2 or cos. Signed-off-by: Arjo Chakravarty <[email protected]> * remove cos change to address one problem at a time Signed-off-by: Arjo Chakravarty <[email protected]> --------- Signed-off-by: Arjo Chakravarty <[email protected]>
@arjo129 Thanks for catching this. |
The changes in #2189 have caused a regression for our upstream users. This fix disables moment calculations by defaulting Cma to zero. It should help mitigate some of the regression. There is also an [ongoing discussion](#2189 (comment)) as to whether the cos term should be cos^2 or cos. Signed-off-by: Arjo Chakravarty <[email protected]> Signed-off-by: Arjo Chakravarty <[email protected]> Co-authored-by: Rhys Mainwaring <[email protected]>
🦟 Bug fix
Fixes #2188
Summary
This PR fixes a bug in the liftdrag plugin that prevented the moment coefficient (cm) from being correctly calculated. The reason for this bug is an mathematical error that calculated cos^2 rather than cos for the cosSweepAngle. Using this updated value, I added in missing calculations from the liftdrag plugin in gazebo-classic, so that the two are now identical in functionality. I also took the opportunity to update the header file to the current formatting and fixed a spelling mistake I found. I also added in the cm_delta parameter that was not present in the current version of the liftdrag plugin but is used by some drones (such as the tailsitter) and may thus find use in the future.
In addition, wind has also been added as a parameter to be considered in calculations, bringing in line with what is present in the gazebo-classic lift drag plugin.
Checklist