Skip to content
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

EKF3: fix EKF reported altitude against public origin #21834

Merged
merged 3 commits into from
Sep 29, 2022

Conversation

tridge
Copy link
Contributor

@tridge tridge commented Sep 29, 2022

This fixes an issue that happens with the following scenario:

  • EK3_AFFINITY=1, giving GPS affinity
  • EK3_SRC1_POSZ=3 using GPS altitude
  • dual GPS enabled
  • at startup the two GPS modules give different AMSL alt
  • this causes XKF1[0].OH and XKF1[1].OH to differ by the GPS height difference
  • the difference in AMSL alt between the GPS modules goes away before takeoff
  • this causes XKF1.PD to compensate for the difference in origin
  • takeoff copter in GUIDED mode
  • we get a temporary glitch that causes a lane change
  • on the new lane the reported above-origin alt changes, causing copter to change altitude (in the provided log it led to a crash)

This PR adds a test that reproduces the issue in SITL and also a fix so that the reported origin uses the public origin and getPosD() in EKF3 adjusts for the difference in origin alt between public origin and the local lane origin

@rmackay9
Copy link
Contributor

I guess we can't remove each core's local origin completely? I suspect this isn't possible because the EKF may update the origin in some rarely used code paths.. but I'd be tempted to remove those code paths (assuming they exist) as well.

@tridge
Copy link
Contributor Author

tridge commented Sep 29, 2022

I guess we can't remove each core's local origin completely?

no, we can't remove those. The EKF constantly moves the local origin to be the current position while flying so that the locally flat-earth assumption is maintained. The public origin doesn't move. This local origin separation is what allows us to fly long distances (say over 1000km) without large errors due to the curvature of the earth

an EKF lane change when the two lanes are using different GPS should
not cause a height change in GUIDED
always use common origin, and adjust output posD for difference
between public and local lane origin heights
@tridge tridge merged commit 17d9018 into ArduPilot:master Sep 29, 2022
@tridge tridge added this to Pending in Plane 4.3 Oct 1, 2022
@tridge tridge moved this from Pending to Merged in Plane 4.3 Oct 1, 2022
@rmackay9 rmackay9 added this to Pending in Copter 4.3 Oct 4, 2022
@tridge tridge moved this from Pending to 4.3.0-beta2 in Copter 4.3 Oct 4, 2022
@tridge tridge moved this from beta1 to beta2 in Plane 4.3 Oct 6, 2022
tridge added a commit to tridge/ardupilot that referenced this pull request Oct 22, 2022
this fixes a bug introduced in ArduPilot#21834

this fix in ArduPilot#21834 was correct for getPosD, but should not have been
applied to getLLH

this caused cruise mode in plane to descend/ascend by the difference
between the public and local origins on mode entry

fixes ArduPilot#21984
tridge added a commit that referenced this pull request Oct 23, 2022
this fixes a bug introduced in #21834

this fix in #21834 was correct for getPosD, but should not have been
applied to getLLH

this caused cruise mode in plane to descend/ascend by the difference
between the public and local origins on mode entry

fixes #21984
tridge added a commit that referenced this pull request Oct 23, 2022
this fixes a bug introduced in #21834

this fix in #21834 was correct for getPosD, but should not have been
applied to getLLH

this caused cruise mode in plane to descend/ascend by the difference
between the public and local origins on mode entry

fixes #21984
rmackay9 pushed a commit to rmackay9/rmackay9-ardupilot that referenced this pull request Oct 24, 2022
this fixes a bug introduced in ArduPilot#21834

this fix in ArduPilot#21834 was correct for getPosD, but should not have been
applied to getLLH

this caused cruise mode in plane to descend/ascend by the difference
between the public and local origins on mode entry

fixes ArduPilot#21984
rmackay9 pushed a commit to rmackay9/rmackay9-ardupilot that referenced this pull request Oct 24, 2022
this fixes a bug introduced in ArduPilot#21834

this fix in ArduPilot#21834 was correct for getPosD, but should not have been
applied to getLLH

this caused cruise mode in plane to descend/ascend by the difference
between the public and local origins on mode entry

fixes ArduPilot#21984
rmackay9 pushed a commit that referenced this pull request Oct 24, 2022
this fixes a bug introduced in #21834

this fix in #21834 was correct for getPosD, but should not have been
applied to getLLH

this caused cruise mode in plane to descend/ascend by the difference
between the public and local origins on mode entry

fixes #21984
rmackay9 pushed a commit that referenced this pull request Oct 24, 2022
this fixes a bug introduced in #21834

this fix in #21834 was correct for getPosD, but should not have been
applied to getLLH

this caused cruise mode in plane to descend/ascend by the difference
between the public and local origins on mode entry

fixes #21984
tridge pushed a commit to tridge/ardupilot that referenced this pull request Dec 7, 2022
this fixes a bug introduced in ArduPilot#21834

this fix in ArduPilot#21834 was correct for getPosD, but should not have been
applied to getLLH

this caused cruise mode in plane to descend/ascend by the difference
between the public and local origins on mode entry

fixes ArduPilot#21984
shellixyz pushed a commit to shellixyz/ardupilot that referenced this pull request Apr 20, 2023
this fixes a bug introduced in ArduPilot#21834

this fix in ArduPilot#21834 was correct for getPosD, but should not have been
applied to getLLH

this caused cruise mode in plane to descend/ascend by the difference
between the public and local origins on mode entry

fixes ArduPilot#21984
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Copter 4.3
4.3.0-beta2
Development

Successfully merging this pull request may close these issues.

None yet

3 participants