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

AP_NavEKF3: revert to primary compass on ground #29300

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rishabsingh3003
Copy link
Contributor

@rishabsingh3003 rishabsingh3003 commented Feb 14, 2025

Revert to the primary compass if it was changed in flight. The compass might have changed because of landing in an area with high mag interference causing a timeout in the magfusion.
Its more than likely the user wants to go back to flying on the primary mag on subsequent takeoff.

Pushed on top of #29299

@tridge
Copy link
Contributor

tridge commented Feb 18, 2025

need to check we don't get an issue with the copter option to save offsets from EKF on disarm, make sure that still works, and saves right offsets for right compass

@rishabsingh3003 rishabsingh3003 force-pushed the ek3_revert_compass_on_takeoff branch from e02757a to ac61dad Compare March 2, 2025 23:44
@rishabsingh3003
Copy link
Contributor Author

I have briefly tested in SITL that the offsets from EKF get saved properly. This happens because its saved before the vehicle actually disarms. The mag gets changed back to primary after saving the offsets.

magFieldLearned = false;
// reset body mag variances on next CovariancePrediction
needMagBodyVarReset = true;
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

remove return

Copy link
Contributor

@tridge tridge left a comment

Choose a reason for hiding this comment

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

looks good to me
@priseborough you OK with this? it matches what we do with primary lane

@tridge tridge requested a review from priseborough March 4, 2025 00:17
@tridge tridge added the EKF label Mar 4, 2025
Copy link
Contributor

@rmackay9 rmackay9 left a comment

Choose a reason for hiding this comment

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

looks good to me

@rmackay9 rmackay9 requested a review from Copilot March 4, 2025 07:11

Choose a reason for hiding this comment

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

PR Overview

This PR adds an integration test to ensure that when the compass is temporarily switched due to a simulated failure in EKF3 during flight, it reverts to the primary compass once on the ground.

  • Introduces the TestEKF3CompassFailover function to simulate compass failure and restoration.
  • Updates the test sequence to include the new failure/recovery scenario within the existing tests2b block.

Reviewed Changes

File Description
Tools/autotest/arducopter.py Adds a new integration test to verify EKF3 compass failover behavior

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

Tools/autotest/arducopter.py:2447

  • [nitpick] Consider revising the docstring for clarity, e.g. 'Test if a switched compass reverts to the primary in EKF3 after disarming'.
'''Test if changed compasses goes back to primary in EKF3 on disarm'''

Tools/autotest/arducopter.py:2479

  • The extra call to land_and_disarm() after 'Compass restored' may be redundant if the vehicle is already disarmed. If this is intentional, please add a comment to clarify its purpose.
self.land_and_disarm()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants