-
Notifications
You must be signed in to change notification settings - Fork 304
Revert to use of cos^2 in LiftDrag plugin #2273
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
Changes from 4 commits
ae85a48
67850c4
a645be8
6d35bfa
71dcdb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,7 @@ class gz::sim::systems::LiftDragPrivate | |
/// \brief Coefficient of Moment / alpha slope. | ||
/// Moment = C_M * q * S | ||
/// where q (dynamic pressure) = 0.5 * rho * v^2 | ||
public: double cma = 0.01; | ||
public: double cma = 0.0; | ||
|
||
/// \brief angle of attach when airfoil stalls | ||
public: double alphaStall = GZ_PI_2; | ||
|
@@ -327,8 +327,9 @@ void LiftDragPrivate::Update(EntityComponentManager &_ecm) | |
double sinSweepAngle = math::clamp( | ||
spanwiseI.Dot(velI), minRatio, maxRatio); | ||
|
||
// get cos from trig identity | ||
double cosSweepAngle = sqrt(1.0 - sinSweepAngle * sinSweepAngle); | ||
// The sweep adjustment depends on the velocity component normal to the wing leading | ||
// edge which appears quadratically in the dynamic pressure, so scale by cos^2 . | ||
double cos2SweepAngle = 1.0 - sinSweepAngle * sinSweepAngle; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @frede791 will this break your models? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, shouldn't be an issue for the PX4 models. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No this is fine. |
||
double sweep = std::asin(sinSweepAngle); | ||
|
||
// truncate sweep to within +/-90 deg | ||
|
@@ -390,20 +391,20 @@ void LiftDragPrivate::Update(EntityComponentManager &_ecm) | |
{ | ||
cl = (this->cla * this->alphaStall + | ||
this->claStall * (alpha - this->alphaStall)) * | ||
cosSweepAngle; | ||
cos2SweepAngle; | ||
// make sure cl is still great than 0 | ||
cl = std::max(0.0, cl); | ||
} | ||
else if (alpha < -this->alphaStall) | ||
{ | ||
cl = (-this->cla * this->alphaStall + | ||
this->claStall * (alpha + this->alphaStall)) | ||
* cosSweepAngle; | ||
* cos2SweepAngle; | ||
// make sure cl is still less than 0 | ||
cl = std::min(0.0, cl); | ||
} | ||
else | ||
cl = this->cla * alpha * cosSweepAngle; | ||
cl = this->cla * alpha * cos2SweepAngle; | ||
|
||
// modify cl per control joint value | ||
if (controlJointPosition && !controlJointPosition->Data().empty()) | ||
|
@@ -421,16 +422,16 @@ void LiftDragPrivate::Update(EntityComponentManager &_ecm) | |
{ | ||
cd = (this->cda * this->alphaStall + | ||
this->cdaStall * (alpha - this->alphaStall)) | ||
* cosSweepAngle; | ||
* cos2SweepAngle; | ||
} | ||
else if (alpha < -this->alphaStall) | ||
{ | ||
cd = (-this->cda * this->alphaStall + | ||
this->cdaStall * (alpha + this->alphaStall)) | ||
* cosSweepAngle; | ||
* cos2SweepAngle; | ||
} | ||
else | ||
cd = (this->cda * alpha) * cosSweepAngle; | ||
cd = (this->cda * alpha) * cos2SweepAngle; | ||
|
||
// make sure drag is positive | ||
cd = std::fabs(cd); | ||
|
@@ -444,20 +445,20 @@ void LiftDragPrivate::Update(EntityComponentManager &_ecm) | |
{ | ||
cm = (this->cma * this->alphaStall + | ||
this->cmaStall * (alpha - this->alphaStall)) | ||
* cosSweepAngle; | ||
* cos2SweepAngle; | ||
// make sure cm is still great than 0 | ||
cm = std::max(0.0, cm); | ||
} | ||
else if (alpha < -this->alphaStall) | ||
{ | ||
cm = (-this->cma * this->alphaStall + | ||
this->cmaStall * (alpha + this->alphaStall)) | ||
* cosSweepAngle; | ||
* cos2SweepAngle; | ||
// make sure cm is still less than 0 | ||
cm = std::min(0.0, cm); | ||
} | ||
else | ||
cm = this->cma * alpha * cosSweepAngle; | ||
cm = this->cma * alpha * cos2SweepAngle; | ||
|
||
// Take into account the effect of control surface deflection angle to cm | ||
if (controlJointPosition && !controlJointPosition->Data().empty()) | ||
|
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.
linter seems unhappy about these lines.