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

EKF: cope better with GPS jamming #24899

Merged
merged 19 commits into from
Jun 9, 2024
Merged

Conversation

tridge
Copy link
Contributor

@tridge tridge commented Sep 6, 2023

This is a revival of #23010
re-opened so I can push to it to get it to pass CI

@tridge
Copy link
Contributor Author

tridge commented Sep 22, 2023

rebaed

@rmackay9
Copy link
Contributor

I think we should try and get this in the near-ish future. Certainly in enough time that it gets some testing before 4.5.0 beta testing.

@tridge
Copy link
Contributor Author

tridge commented Sep 25, 2023

@priseborough this is failing the dead-reckoning CI test. The EK3 position is resetting on loss of GPS for some reason.
I've put a replay log here:
http://uav.tridgell.net/tmp/ArduPlane-DeadreckoningNoAirSpeed-00000003.BIN

@tridge
Copy link
Contributor Author

tridge commented Sep 26, 2023

image

@priseborough
Copy link
Contributor

priseborough commented Sep 26, 2023

@priseborough this is failing the dead-reckoning CI test. The EK3 position is resetting on loss of GPS for some reason.
I've put a replay log here:
http://uav.tridgell.net/tmp/ArduPlane-DeadreckoningNoAirSpeed-00000003.BIN

The underlying issue is that the EKF in the no airspeed sensor case is not fusing in a synthetic airspeed to constrain along track drift and is falling out of dead reckoning within a few seconds of GPS being lost. Setting FLIGHT_OPTIONS bit 7 will cause the EKF to use a default airspeed halfway between ARSPD_FBW_MAX and ARSPD_FBW_MIN which for SITL is between 30 and 10. I will see if I can adjust the SITL parameters so that the vehicle cruises at 20 m/s with no airspeed sensor and set that bit in FLIGHT_OPTIONS and get the dead reckoning working for the no airspeed sensor case.

Edit: There is a bug in the logic that decides when to use a default or synthesised airspeed value that prevents either being used if there is an airspeed sensor fitted but its use is disabled.

@priseborough
Copy link
Contributor

There are multiple contributing issues:

  1. A bug that prevented synthetic or default airspeed being used for dead reckoning if airspeed data was being received but had been disabled by parameter.
  2. Synthetic airspeed and sideslip was not constraining velocity drift sufficiently. For the no airspeed sensor use case using wind states learned prior to loss of GPs as a truth 'truth' reference has fixes this.
  3. Learning wind takes longer if there is no airspeed sensor and the autotest was not allowing sufficient time.
  4. The GPS jamming was not causing the EKF to stop using the GPS completely, instead because the duration of loss of lock and large errors was relatively short the EKF was instead using the innovation consistency checks to protect against bad estimates. This is actually working, bit not what the autotest was looking for which was a delayed resumption of GPs use while quality checks waited to pass.

There were other issues found:

  1. Planes might never register the in flight yaw alignment complete if the yaw misalignment was small
  2. When resuming GPS use wind state learning should be faster

I am currently testing fixes for these and will submit a PR against the branch.

@tridge
Copy link
Contributor Author

tridge commented Sep 30, 2023

rebased

@tridge tridge force-pushed the pr-ekf-gps-check-fix branch 2 times, most recently from e4528bb to df8e53d Compare October 7, 2023 04:55
@tridge
Copy link
Contributor Author

tridge commented Nov 4, 2023

rebased and cleaned up AP_AHRS options handling code

@tridge
Copy link
Contributor Author

tridge commented Nov 4, 2023

@priseborough the Deadreckoning test is failing in an interesting way:
image

@tridge
Copy link
Contributor Author

tridge commented Dec 1, 2023

rebased on #25676

@tridge tridge force-pushed the pr-ekf-gps-check-fix branch 2 times, most recently from bf3aec6 to 686a340 Compare December 6, 2023 07:37
@rmackay9
Copy link
Contributor

No pressure but I wonder if we should try and include this in 4.5.0.

@tridge
Copy link
Contributor Author

tridge commented May 29, 2024

I've amended the time threshold which allows the dead reckoning test to pass - priseborough@ae2e1bf

thanks Paul! I've added that commit to this branch and rebased on master

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.

Could we pull in this change to the new EK3_OPTIONS parameter descriptions? I'm sorry to be so persistent. https://github.com/rmackay9/rmackay9-ardupilot/commits/tridge-pr-ekf-gps-check-fix/

@tridge
Copy link
Contributor Author

tridge commented May 29, 2024

Could we pull in this change to the new EK3_OPTIONS parameter descriptions? I'm sorry to be so persistent. https://github.com/rmackay9/rmackay9-ardupilot/commits/tridge-pr-ekf-gps-check-fix/

applied, sorry for being slow on this!

Paul Riseborough and others added 19 commits June 9, 2024 11:12
These changes enable the EKF to use the last observable wind velocity vector estimate to synthesise an airspeed measurement if operating without an airspeed sensor and when all other measurement types that can constrain velocoty drift are lost. This enables the EKF to use dead reckoning to continue after loss of GPS when there is no air speed sensor fitted and without the need to set a default airspeed value.
The logic used to fuse a default airspeed value has also been cleaned up and the call to FuseAirSpeed() from inside SelectBetaDragFusion() has been removed.

AP_NavEKF3: Fix error in default airspeed observation variance

AP_NavEKF3: Enable shadow fusion of airspeed when sensor is disabled
These changes prevent the EKF from consuming GPS data too soon when it is recovering from jamming if the EKF is able to navigate using dead reckoning.
Explicitly test time taken to reset to GPS loss and regain of lock for copter without and plane with dead reckoning assistance.
Make it user selectable.
Remove potential for a race condition between decisions based on latest data and the EKF fusion processing which operates on a delayed time horizon. This is achieved by preventing data entering the buffer if awaiting checks to pass ensuring that no EKF fusion time horizon processes can use data that hasn't passed checks.
Log the waitingForGpsChecks class variable
The previous method resulted in data incest and fusion of predicted airspeed on every EKF internal time step.
This was not apparent during flight where the vehicle was turning, but during long straight legs did not constrain along track drift.
@tridge tridge merged commit 5c76e77 into ArduPilot:master Jun 9, 2024
92 checks passed
@rmackay9
Copy link
Contributor

yeah!! great to see this go in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EKF SITL WikiNeeded needs wiki update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants