Skip to content

Conversation

@breadoven
Copy link
Collaborator

@breadoven breadoven commented Jan 22, 2026

User description

Should provide a fix for #10360, #10391, #10893 and #11049.

See #11049 (comment) for explanation and reason for change.

HITL testing shows the estimate instability is fixed with the PR changes. Not easy to flight test given the odd set of circumstances need to trigger the problem in the first place.

INAV_EST_CORR_LIMIT_VALUE may need tweaking. It corresponds to around 40m residual error for x/y position at the default loop rate.


PR Type

Bug fix


Description

  • Fix position estimator instability by directly resetting estimates instead of accumulating corrections

  • Add correction limiting to prevent excessive estimate adjustments per loop iteration

  • Constrain uncertainty estimates to prevent unbounded growth

  • Simplify velocity decay calculation and improve code clarity


Diagram Walkthrough

flowchart LR
  A["Invalid Estimate Detection"] -->|Direct Reset| B["Position/Velocity Set to GPS"]
  C["Correction Calculation"] -->|Limit Corrections| D["Constrained Corrections Applied"]
  E["Uncertainty Update"] -->|Bounded Growth| F["Capped EPH/EPV Values"]
  B --> D
  D --> F
Loading

File Walkthrough

Relevant files
Bug fix
navigation_pos_estimator.c
Correct estimate initialization and add correction limits

src/main/navigation/navigation_pos_estimator.c

  • Changed invalid estimate initialization from accumulating corrections
    to directly resetting position and velocity to GPS values
  • Added correction limiting loop to constrain position and velocity
    corrections within INAV_EST_CORR_LIMIT_VALUE bounds
  • Simplified velocity decay calculations by removing redundant 0.0f -
    operations
  • Added constraints to EPH and EPV uncertainty estimates to prevent
    unbounded growth
  • Improved code formatting with consistent spacing
  • Changed loop variable declaration from int to uint8_t for type
    consistency
+20/-14 
Configuration changes
navigation_pos_estimator_private.h
Define correction limit constant                                                 

src/main/navigation/navigation_pos_estimator_private.h

  • Added new constant INAV_EST_CORR_LIMIT_VALUE set to 2.0f to limit
    maximum position/velocity correction per loop iteration
  • Constant corresponds to approximately 40m residual error for x/y
    position at default loop rate
+2/-0     

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Jan 22, 2026

PR Compliance Guide 🔍

All compliance sections have been disabled in the configurations.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant