Skip to content

AP_Soaring: guard variometer calculations#32821

Draft
vlordier wants to merge 1 commit intoArduPilot:masterfrom
vlordier:pr/ap-soaring-variometer-guards
Draft

AP_Soaring: guard variometer calculations#32821
vlordier wants to merge 1 commit intoArduPilot:masterfrom
vlordier:pr/ap-soaring-variometer-guards

Conversation

@vlordier
Copy link
Copy Markdown

@vlordier vlordier commented Apr 18, 2026

This draft isolates the variometer guard changes from the larger hardening branch.

Summary:

  • add defensive handling for degenerate sinkrate / circling time calculations
  • add focused regression coverage for CL0 == 0 fallback handling and level-flight bank divide-by-zero protection
  • include the small variometer member initialization changes that came with this slice

Why:

  • this is a coherent subsystem-local change set
  • it is more reviewable on its own than inside the original monolithic PR

Validation:

  • branch was split cleanly from upstream/master
  • the branch includes focused regression test source for the degenerate variometer calculation cases in this slice
  • not fully validated locally as a standalone branch beyond the split and commit flow
  • draft only pending subsystem review

Comment on lines 19 to 62
@@ -56,9 +56,9 @@ class Variometer {

Variometer(const AP_FixedWing &parms, const PolarParams &polarParams);

float alt;
float reading;
float tau;
float alt{0.0f};
float reading{0.0f};
float tau{0.0f};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to init to zero.

float C2; // C2 = CDi0/CL0 = B*CL0
CL0 = _polarParams.K / (_aspd_filt_constrained * _aspd_filt_constrained);

// When K is zero or airspeed is extremely high, CL0 approaches zero.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah perfect, AP is flying a rocket near light speed. Very realistic corner case that we should handle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants