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

Reduce vulnerability of planes to bad GPS data #23010

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

Conversation

priseborough
Copy link
Contributor

@priseborough priseborough commented Feb 22, 2023

When GPS interference is severe enough to result in loss of lock, the position and velocity errors can initially large when the interference reduces and the receiver regains lock. The existing code prioritises a fast reset and will use the first 3D fix available. Whilst this may be an acceptable risk if the receiver is doing inertial only dead reckoning with unconstrained velocity drift (eg copters without optical flow), planes using air data have there velocity drift constrained and should wait a few seconds for quality checks to pass.

The following figures show an example of this behaviour where interference during a flight has caused the GPS to lose lock and then it regains lock for one frame but with very large height and velocity errors.

image
image

The SITL testing of these changes also revealed that when no airspeed sensor is being used, planes are falling back to dead reckoning using DCM because the EKF was not able to constrain velocity error buildup in the direction of travel. A patch has been added which will continue navigating using the last estimated wind drift to synthesise an airspeed measurement if GPS is lost and airspeed sensor use is disabled or if use of a default airspeed has not been set using bit 7 of FLIGHT_OPTIONS.

@priseborough priseborough requested a review from tridge February 22, 2023 23:30
@priseborough priseborough self-assigned this Feb 22, 2023
@priseborough priseborough force-pushed the pr-ekf-gps-check-fix branch 4 times, most recently from d97cc8e to 8c508ab Compare February 28, 2023 03:19
@tkoivuro
Copy link

tkoivuro commented Mar 2, 2023

Does same apply to dual GPS setups where primary GPS starts failing and ardupilot is only looking at the fix status and never changes over to the 2nd GPS unit.

When using GPS altitude from primary high precision GPS we have experienced at least 3 crashes just like this:

image

Cause of loss of lock was antenna or antenna cable damage. GPS Autoswitch never switched over to backup and plane ended up in pieces.

@priseborough priseborough force-pushed the pr-ekf-gps-check-fix branch from 9178463 to de8d4a0 Compare March 6, 2023 23:41
@priseborough
Copy link
Contributor Author

priseborough commented Mar 7, 2023

Does same apply to dual GPS setups where primary GPS starts failing and ardupilot is only looking at the fix status and never changes over to the 2nd GPS unit.

When using GPS altitude from primary high precision GPS we have experienced at least 3 crashes just like this:
[figure removed]
Cause of loss of lock was antenna or antenna cable damage. GPS Autoswitch never switched over to backup and plane ended up in pieces.

The system response to the fault condition you are describing is not addressed by these changes. Have you raised an issue and provided a log?

The GPS selection code relies on the receivers correctly reporting their accuracy. If your primary GPS did report a bad vertical accuracy, then use of the GPS blending feature activated when GPS_AUTO_SWITCH = 2 may have helped. If height accuracy is critical for the GPS use, then GPS_BLEND_MASK should be set to 6 ( or 2) instead of 5 so that reported velocity and vertical position or vertical position only is used as t the criteria for weighting the two solutions. None of this will help if the GPS receiver is reporting good lock status and accuracy, but is outputting bad data as the GPS selector does not sanity check the data.

If the GPS' own accuracy reporting cannot be relied on, the EKF can be set up so that each EKF instance (using it's own IMU) will use a separate GPS via the EK3_AFFINITY parameter and relying on the EKF voting/selection algorithm. If you use this feature, make sure your preferred GPS is being used by the EKF instance specified as the primary by the EK3_PRIMARY parameter.

@priseborough priseborough changed the title Reduce vulnerability to bad GPS data when recovering from loss of lock Reduce vulnerability of planes to bad GPS data Mar 7, 2023
@priseborough
Copy link
Contributor Author

I've pulled in the patches from #23173 and used the simulated GPS jamming in one of the auto tests. This highlighted a vulnerability whereby of the GPS was providing a jam effected 3-D fix with lots of position error and the EKF was successfully dead reckoning, the DCM would be selected and the planes navigation controller would respond to the jam affected GPS position. This vulnerability has been fixed.

@@ -1821,13 +1821,14 @@ AP_AHRS::EKFType AP_AHRS::active_EKF_type(void) const
if (hal.util->get_soft_armed() &&
(!filt_state.flags.using_gps ||
!filt_state.flags.horiz_pos_abs) &&
!filt_state.flags.horiz_pos_rel &&
Copy link
Contributor

@tridge tridge Mar 21, 2023

Choose a reason for hiding this comment

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

this is a tricky one. It means that we are trusting the EKF to judge if it can provide a horizontal position. When flying in an area where jamming may be expected then this is obviously a good change. If flying in an area where jamming is not expected then I think it is far more likely that the EKF is wrong and the GPS is right (which is why this whole fallback to DCM logic is there). The EKF does sometimes go bad, either with vibration or bad yaw from GSF (especially if no compass).
Maybe we need an AHRS_OPTIONS bit for when we are flying in an area where jamming is expected?

@tridge
Copy link
Contributor

tridge commented May 13, 2023

@priseborough I think we need an AHRS_OPTIONS bit that enables protections against GPS interference. For now it would just change the DCM fallback decision, but could be used more extensively later

@tridge
Copy link
Contributor

tridge commented Jun 6, 2023

@priseborough I've added AHRS_OPTIONS in this branch
https://github.com/tridge/ardupilot/commits/pr-ekf-gps-check-fix
I can't push to your PR branch as I don't have permission

@priseborough priseborough force-pushed the pr-ekf-gps-check-fix branch from c4632c1 to e459e49 Compare June 7, 2023 03:37
Paul Riseborough and others added 9 commits June 25, 2023 17:23
Explicitly test time taken to reset to GPS loss and regain of lock for copter without and plane with dead reckoning assistance.
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
this is based on some test logs from using a real jammer in controlled
test flights
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.
…iour

The AHRS will no longer switch to DCM if the EKF is doing dead reckoning with constrained velocity errors and there is a GPS fix so checking for the "EKF3 Active" message no longer works
the first option is to disable DCM fallback on fixed wing. This is
suitable in environments with a high likelyhood of GPS interference
@priseborough priseborough force-pushed the pr-ekf-gps-check-fix branch from e459e49 to 75bf81d Compare June 25, 2023 07:24
@priseborough
Copy link
Contributor Author

@tridge I rebased and included your patch for the AHRS_OPTIONS bit to disable the DCM fallback.

@tridge
Copy link
Contributor

tridge commented Sep 6, 2023

@priseborough I've rebased this on master and pushed to this branch:
https://github.com/tridge/ardupilot/tree/pr-ekf-gps-check-fix

@tridge
Copy link
Contributor

tridge commented Sep 7, 2023

@priseborough I've opened a new PR for sheparding this through CI: #24899

@moreba1
Copy link

moreba1 commented Feb 2, 2025

Hi
Does this was solved ?

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.

4 participants