-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Adjust TPA parameters for fixed-wing aircraft #11237
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 all commits
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 |
|---|---|---|
|
|
@@ -446,7 +446,7 @@ static float calculateFixedWingAirspeedTPAFactor(void){ | |
| const float airspeed = constrainf(getAirspeedEstimate(), 100.0f, 20000.0f); // cm/s, clamped to 3.6-720 km/h | ||
| const float referenceAirspeed = pidProfile()->fixedWingReferenceAirspeed; // in cm/s | ||
| float tpaFactor= powf(referenceAirspeed/airspeed, currentControlProfile->throttle.apa_pow/100.0f); | ||
| tpaFactor= constrainf(tpaFactor, 0.3f, 1.5f); | ||
| tpaFactor= constrainf(tpaFactor, 0.3f, 2.0f); | ||
| return tpaFactor; | ||
| } | ||
|
Comment on lines
446
to
451
Contributor
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. Suggestion: Add a defensive fallback when New proposed code: static float calculateFixedWingAirspeedTPAFactor(void){
const float airspeed = constrainf(getAirspeedEstimate(), 100.0f, 20000.0f); // cm/s, clamped to 3.6-720 km/h
const float referenceAirspeed = pidProfile()->fixedWingReferenceAirspeed; // in cm/s
- float tpaFactor= powf(referenceAirspeed/airspeed, currentControlProfile->throttle.apa_pow/100.0f);
- tpaFactor= constrainf(tpaFactor, 0.3f, 2.0f);
+ const float exponent = currentControlProfile->throttle.apa_pow / 100.0f;
+
+ if (!(referenceAirspeed > 0.0f) || !isfinite(referenceAirspeed) || !isfinite(exponent)) {
+ return 1.0f;
+ }
+
+ float tpaFactor = powf(referenceAirspeed / airspeed, exponent);
+ tpaFactor = constrainf(tpaFactor, 0.3f, 2.0f);
return tpaFactor;
} |
||
|
|
||
|
|
||
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.
Suggestion: Add a check to ensure
tpaFactoris a finite number before theconstrainfcall to prevent potential propagation ofNaNorinfvalues. [possible issue, importance: 7]