diff --git a/Tools/ecl_ekf/analyse_logdata_ekf.py b/Tools/ecl_ekf/analyse_logdata_ekf.py index 70b8da5582d..ce3117096b2 100644 --- a/Tools/ecl_ekf/analyse_logdata_ekf.py +++ b/Tools/ecl_ekf/analyse_logdata_ekf.py @@ -11,7 +11,6 @@ from pyulog import ULog from analysis.detectors import InAirDetector, PreconditionError from analysis.metrics import calculate_ecl_ekf_metrics from analysis.checks import perform_ecl_ekf_checks -from analysis.post_processing import get_gps_check_fail_flags def analyse_ekf( ulog: ULog, check_levels: Dict[str, float], multi_instance: int = 0, @@ -66,8 +65,6 @@ def analyse_ekf( 'in_air_transition_time': round(in_air.take_off + in_air.log_start, 2), 'on_ground_transition_time': round(in_air.landing + in_air.log_start, 2)} - gps_fail_flags = get_gps_check_fail_flags(estimator_status) - sensor_checks, innov_fail_checks = find_checks_that_apply( estimator_status_flags, estimator_status, pos_checks_when_sensors_not_fused=pos_checks_when_sensors_not_fused) diff --git a/Tools/ecl_ekf/analysis/post_processing.py b/Tools/ecl_ekf/analysis/post_processing.py index 26c0bbb3450..285908671f0 100644 --- a/Tools/ecl_ekf/analysis/post_processing.py +++ b/Tools/ecl_ekf/analysis/post_processing.py @@ -7,34 +7,26 @@ from typing import Tuple import numpy as np -def get_gps_check_fail_flags(estimator_status: dict) -> dict: +def get_gnss_failed_checks(vehicle_gnss: dict) -> dict: """ - :param estimator_status: - :return: + :param vehicle_gnss: the selected receiver's samples + :return: one array per check, 1 where the check failed """ - gps_fail_flags = dict() + # vehicle_gnss CHECK_* bits + check_bits = { + 'nsat_fail': 0, + 'pdop_fail': 1, + 'herr_fail': 2, + 'verr_fail': 3, + 'serr_fail': 4, + 'hdrift_fail': 5, + 'vdrift_fail': 6, + 'hspd_fail': 7, + 'veld_diff_fail': 8, + 'gfix_fail': 10, + } - # 0 : insufficient fix type (no 3D solution) - # 1 : minimum required sat count fail - # 2 : maximum allowed PDOP fail - # 3 : maximum allowed horizontal position error fail - # 4 : maximum allowed vertical position error fail - # 5 : maximum allowed speed error fail - # 6 : maximum allowed horizontal position drift fail - # 7 : maximum allowed vertical position drift fail - # 8 : maximum allowed horizontal speed fail - # 9 : maximum allowed vertical velocity discrepancy fail - gps_fail_flags['gfix_fail'] = ((2 ** 0 & estimator_status['gps_check_fail_flags']) > 0) * 1 - gps_fail_flags['nsat_fail'] = ((2 ** 1 & estimator_status['gps_check_fail_flags']) > 0) * 1 - gps_fail_flags['pdop_fail'] = ((2 ** 2 & estimator_status['gps_check_fail_flags']) > 0) * 1 - gps_fail_flags['herr_fail'] = ((2 ** 3 & estimator_status['gps_check_fail_flags']) > 0) * 1 - gps_fail_flags['verr_fail'] = ((2 ** 4 & estimator_status['gps_check_fail_flags']) > 0) * 1 - gps_fail_flags['serr_fail'] = ((2 ** 5 & estimator_status['gps_check_fail_flags']) > 0) * 1 - gps_fail_flags['hdrift_fail'] = ((2 ** 6 & estimator_status['gps_check_fail_flags']) > 0) * 1 - gps_fail_flags['vdrift_fail'] = ((2 ** 7 & estimator_status['gps_check_fail_flags']) > 0) * 1 - gps_fail_flags['hspd_fail'] = ((2 ** 8 & estimator_status['gps_check_fail_flags']) > 0) * 1 - gps_fail_flags['veld_diff_fail'] = ((2 ** 9 & estimator_status['gps_check_fail_flags']) > 0) * 1 - return gps_fail_flags + return {name: ((2 ** bit & vehicle_gnss['failed_checks']) > 0) * 1 for name, bit in check_bits.items()} def magnetic_field_estimates_from_states(estimator_states: dict) -> Tuple[float, float, float]: diff --git a/Tools/ecl_ekf/plotting/pdf_report.py b/Tools/ecl_ekf/plotting/pdf_report.py index 3daf82efb0d..2520cada783 100644 --- a/Tools/ecl_ekf/plotting/pdf_report.py +++ b/Tools/ecl_ekf/plotting/pdf_report.py @@ -11,7 +11,7 @@ import numpy as np from matplotlib.backends.backend_pdf import PdfPages from pyulog import ULog -from analysis.post_processing import magnetic_field_estimates_from_states, get_gps_check_fail_flags +from analysis.post_processing import magnetic_field_estimates_from_states, get_gnss_failed_checks from plotting.data_plots import TimeSeriesPlot, InnovationPlot, ControlModeSummaryPlot, \ CheckFlagsPlot from analysis.detectors import PreconditionError @@ -78,7 +78,13 @@ def create_pdf_report(ulog: ULog, multi_instance: int, output_plot_filename: str except: raise PreconditionError('could not find innovation data') - gps_fail_flags = get_gps_check_fail_flags(estimator_status) + try: + vehicle_gnss = ulog.get_dataset('vehicle_gnss').data + gps_fail_flags = get_gnss_failed_checks(vehicle_gnss) + gnss_time = 1e-6 * vehicle_gnss['timestamp'] + except: + gps_fail_flags = None + print('could not find vehicle_gnss, the GNSS check failures are not plotted') status_time = 1e-6 * estimator_status['timestamp'] status_flags_time = 1e-6 * estimator_status_flags['timestamp'] @@ -240,18 +246,19 @@ def create_pdf_report(ulog: ULog, multi_instance: int, output_plot_filename: str data_plot.save() data_plot.close() - # gps_check_fail_flags summary - data_plot = CheckFlagsPlot( - status_time, gps_fail_flags, - [['nsat_fail', 'pdop_fail', 'herr_fail', 'verr_fail', 'gfix_fail', 'serr_fail'], - ['hdrift_fail', 'vdrift_fail', 'hspd_fail', 'veld_diff_fail']], - x_label='time (sec)', y_lim=(-0.1, 1.1), y_labels=['failed', 'failed'], - sub_titles=['GPS Direct Output Check Failures', 'GPS Derived Output Check Failures'], - legend=[['N sats', 'PDOP', 'horiz pos error', 'vert pos error', 'fix type', - 'speed error'], ['horiz drift', 'vert drift', 'horiz speed', - 'vert vel inconsistent']], annotate=False, pdf_handle=pdf_pages) - data_plot.save() - data_plot.close() + # failed checks of the selected GNSS receiver + if gps_fail_flags is not None: + data_plot = CheckFlagsPlot( + gnss_time, gps_fail_flags, + [['nsat_fail', 'pdop_fail', 'herr_fail', 'verr_fail', 'gfix_fail', 'serr_fail'], + ['hdrift_fail', 'vdrift_fail', 'hspd_fail', 'veld_diff_fail']], + x_label='time (sec)', y_lim=(-0.1, 1.1), y_labels=['failed', 'failed'], + sub_titles=['GPS Direct Output Check Failures', 'GPS Derived Output Check Failures'], + legend=[['N sats', 'PDOP', 'horiz pos error', 'vert pos error', 'fix type', + 'speed error'], ['horiz drift', 'vert drift', 'horiz speed', + 'vert vel inconsistent']], annotate=False, pdf_handle=pdf_pages) + data_plot.save() + data_plot.close() # filter reported accuracy data_plot = CheckFlagsPlot( diff --git a/docs/en/advanced_config/tuning_the_ecl_ekf.md b/docs/en/advanced_config/tuning_the_ecl_ekf.md index 817a005b9ae..e9e6e979bb0 100644 --- a/docs/en/advanced_config/tuning_the_ecl_ekf.md +++ b/docs/en/advanced_config/tuning_the_ecl_ekf.md @@ -739,9 +739,9 @@ For a binary pass/fail summary for each sensor, refer to innovation_check_flags The EKF applies a number of GPS quality checks before commencing GPS aiding. These checks are controlled by the [GNSS_CHECK](../advanced_config/parameter_reference.md#GNSS_CHECK) and `GNSS_REQ_*` parameters. -The pass/fail status for these checks is logged in the [EstimatorStatus](https://github.com/PX4/PX4-Autopilot/blob/main/msg/EstimatorStatus.msg).gps_check_fail_flags message. +The pass/fail status for these checks is logged in [VehicleGnss](../msg_docs/VehicleGnss.md) `failed_checks` for the selected receiver, and in [SensorsStatusGnss](../msg_docs/SensorsStatusGnss.md) `failed_checks` for each receiver. This integer will be zero when all required GPS checks have passed. -If the EKF is not commencing GPS alignment, check the value of the integer against the bitmask definition `gps_check_fail_flags` in [EstimatorStatus](https://github.com/PX4/PX4-Autopilot/blob/main/msg/EstimatorStatus.msg). +If the EKF is not commencing GPS alignment, check the value of the integer against the `CHECK_*` bits in [VehicleGnss](../msg_docs/VehicleGnss.md), and why the EKF does not fuse the samples in [EstimatorStatusFlags](../msg_docs/EstimatorStatusFlags.md) `gnss_fusion_state`. ### EKF Numerical Errors @@ -758,7 +758,7 @@ To prevent this, every covariance and state update step contains the following e - An upper limit is applied to state variances. - Symmetry is forced on the covariance matrix. -After re-tuning the filter, particularly re-tuning that involve reducing the noise variables, the value of `estimator_status.gps_check_fail_flags` should be checked to ensure that it remains zero. +After re-tuning the filter, particularly re-tuning that involve reducing the noise variables, the value of `estimator_status.filter_fault_flags` should be checked to ensure that it remains zero. ## What should I do if the height estimate is diverging? diff --git a/docs/en/flying/pre_flight_checks.md b/docs/en/flying/pre_flight_checks.md index 0a5d652e96d..d1c7facb5a2 100644 --- a/docs/en/flying/pre_flight_checks.md +++ b/docs/en/flying/pre_flight_checks.md @@ -41,7 +41,7 @@ The QGC Arming Checks UI is available in the QGC Daily Build (QGC v4.2.0 and lat ## Flight Logs Preflight errors are also reported in _QGroundControl_ as `PREFLIGHT FAIL` messages. -The `estimator_status.gps_check_fail_flags` message [in the logs](../getting_started/flight_reporting.md) shows which GPS quality checks are failing. +The `vehicle_gnss.failed_checks` field [in the logs](../getting_started/flight_reporting.md) shows which GPS quality checks the selected receiver fails, and `sensors_status_gnss.failed_checks` those of each receiver. Note that the [Arming Check Report](#qgc-arming-check-report) is a much easier way to determine reasons for failure, but the logs may be useful in versions prior to PX4 v1.14. diff --git a/msg/EstimatorStatus.msg b/msg/EstimatorStatus.msg index e6714ff4f53..5b14d807495 100644 --- a/msg/EstimatorStatus.msg +++ b/msg/EstimatorStatus.msg @@ -3,22 +3,6 @@ uint64 timestamp_sample # the timestamp of the raw data (microseconds) float32[3] output_tracking_error # return a vector containing the output predictor angular, velocity and position tracking error magnitudes (rad), (m/s), (m) -uint16 gps_check_fail_flags # Bitmask to indicate status of GPS checks - see definition below -# bits are true when corresponding test has failed -uint8 GPS_CHECK_FAIL_GPS_FIX = 0 # 0 : insufficient fix type (no 3D solution) -uint8 GPS_CHECK_FAIL_MIN_SAT_COUNT = 1 # 1 : minimum required sat count fail -uint8 GPS_CHECK_FAIL_MAX_PDOP = 2 # 2 : maximum allowed PDOP fail -uint8 GPS_CHECK_FAIL_MAX_HORZ_ERR = 3 # 3 : maximum allowed horizontal position error fail -uint8 GPS_CHECK_FAIL_MAX_VERT_ERR = 4 # 4 : maximum allowed vertical position error fail -uint8 GPS_CHECK_FAIL_MAX_SPD_ERR = 5 # 5 : maximum allowed speed error fail -uint8 GPS_CHECK_FAIL_MAX_HORZ_DRIFT = 6 # 6 : maximum allowed horizontal position drift fail - requires stationary vehicle -uint8 GPS_CHECK_FAIL_MAX_VERT_DRIFT = 7 # 7 : maximum allowed vertical position drift fail - requires stationary vehicle -uint8 GPS_CHECK_FAIL_MAX_HORZ_SPD_ERR = 8 # 8 : maximum allowed horizontal speed fail - requires stationary vehicle -uint8 GPS_CHECK_FAIL_MAX_VERT_SPD_ERR = 9 # 9 : maximum allowed vertical velocity discrepancy fail -uint8 GPS_CHECK_FAIL_SPOOFED = 10 # 10 : GPS signal is spoofed -uint8 GPS_CHECK_FAIL_JAMMED = 11 # 11 : GPS signal is jammed -uint8 GPS_CHECK_FAIL_HKIN = 12 # 12 : GPS horizontal position change inconsistent with velocity - uint64 control_mode_flags # Bitmask to indicate EKF logic state uint8 CS_TILT_ALIGN = 0 # 0 - true if the filter tilt alignment is complete uint8 CS_YAW_ALIGN = 1 # 1 - true if the filter yaw alignment is complete diff --git a/src/drivers/ins/microstrain/MicroStrain.cpp b/src/drivers/ins/microstrain/MicroStrain.cpp index 048e0b8cd73..3b069c44cea 100755 --- a/src/drivers/ins/microstrain/MicroStrain.cpp +++ b/src/drivers/ins/microstrain/MicroStrain.cpp @@ -1525,8 +1525,6 @@ void MicroStrain::filterCallback(void *user, const mip_packet *packet, mip::Time status.output_tracking_error[1] = 0; status.output_tracking_error[2] = 0; - status.gps_check_fail_flags = 0; - // Minimal mapping of error flags from device to the PX4 health flags status.control_mode_flags = stat.sample.filter_state == 4 ? (0x1ULL << estimator_status_s::CS_GNSS_POS) | (0x1ULL << estimator_status_s::CS_GNSS_VEL) | diff --git a/src/modules/ekf2/EKF2.cpp b/src/modules/ekf2/EKF2.cpp index c7f02ad9a82..b1d0605ea02 100644 --- a/src/modules/ekf2/EKF2.cpp +++ b/src/modules/ekf2/EKF2.cpp @@ -49,39 +49,6 @@ static px4::atomic _ekf2_selector {nullptr}; #endif // CONFIG_EKF2_MULTI_INSTANCE #if defined(CONFIG_EKF2_GNSS) -// estimator_status reports the failed GNSS checks in its own bit order, which commander and the logs read -static uint16_t toEstimatorStatusCheckFlags(uint16_t failed_checks) -{ - static constexpr struct { - uint16_t check; - uint8_t bit; - } kCheckBits[] { - {vehicle_gnss_s::CHECK_FIX, estimator_status_s::GPS_CHECK_FAIL_GPS_FIX}, - {vehicle_gnss_s::CHECK_NSATS, estimator_status_s::GPS_CHECK_FAIL_MIN_SAT_COUNT}, - {vehicle_gnss_s::CHECK_PDOP, estimator_status_s::GPS_CHECK_FAIL_MAX_PDOP}, - {vehicle_gnss_s::CHECK_EPH, estimator_status_s::GPS_CHECK_FAIL_MAX_HORZ_ERR}, - {vehicle_gnss_s::CHECK_EPV, estimator_status_s::GPS_CHECK_FAIL_MAX_VERT_ERR}, - {vehicle_gnss_s::CHECK_SACC, estimator_status_s::GPS_CHECK_FAIL_MAX_SPD_ERR}, - {vehicle_gnss_s::CHECK_HDRIFT, estimator_status_s::GPS_CHECK_FAIL_MAX_HORZ_DRIFT}, - {vehicle_gnss_s::CHECK_VDRIFT, estimator_status_s::GPS_CHECK_FAIL_MAX_VERT_DRIFT}, - {vehicle_gnss_s::CHECK_HSPEED, estimator_status_s::GPS_CHECK_FAIL_MAX_HORZ_SPD_ERR}, - {vehicle_gnss_s::CHECK_VSPEED, estimator_status_s::GPS_CHECK_FAIL_MAX_VERT_SPD_ERR}, - {vehicle_gnss_s::CHECK_SPOOFED, estimator_status_s::GPS_CHECK_FAIL_SPOOFED}, - {vehicle_gnss_s::CHECK_JAMMED, estimator_status_s::GPS_CHECK_FAIL_JAMMED}, - {vehicle_gnss_s::CHECK_HKIN, estimator_status_s::GPS_CHECK_FAIL_HKIN}, - }; - - uint16_t flags = 0; - - for (const auto &check_bit : kCheckBits) { - if (failed_checks & check_bit.check) { - flags |= 1u << check_bit.bit; - } - } - - return flags; -} - static_assert(static_cast(GnssFusionState::Fused) == estimator_status_flags_s::GNSS_FUSION_FUSED); static_assert(static_cast(GnssFusionState::NoData) == estimator_status_flags_s::GNSS_FUSION_NO_DATA); static_assert(static_cast(GnssFusionState::Unusable) == estimator_status_flags_s::GNSS_FUSION_UNUSABLE); @@ -1924,16 +1891,6 @@ void EKF2::PublishStatus(const hrt_abstime ×tamp) _ekf.getOutputTrackingError().copyTo(status.output_tracking_error); -#if defined(CONFIG_EKF2_GNSS) - - // Only while GNSS fusion is enabled, as when EKF2 ran the checks itself: commander turns a failure into a pre-arm - // failure, and a receiver EKF2 ignores must not cause one - if (_param_ekf2_gps_ctrl.get() != 0) { - status.gps_check_fail_flags = toEstimatorStatusCheckFlags(_gnss_failed_checks); - } - -#endif // CONFIG_EKF2_GNSS - status.control_mode_flags = _ekf.control_status().value; status.filter_fault_flags = _ekf.fault_status().value; @@ -2517,7 +2474,6 @@ void EKF2::UpdateGnssSample(ekf2_timestamps_s &ekf2_timestamps) if (_vehicle_gnss_sub.update(&vehicle_gnss)) { - _gnss_failed_checks = vehicle_gnss.strict ? vehicle_gnss.failed_strict_checks : vehicle_gnss.failed_relaxed_checks; Vector3f vel_ned; diff --git a/src/modules/ekf2/EKF2.hpp b/src/modules/ekf2/EKF2.hpp index 724a4acbdc7..f83f9bf0f4d 100644 --- a/src/modules/ekf2/EKF2.hpp +++ b/src/modules/ekf2/EKF2.hpp @@ -474,8 +474,6 @@ private: float _last_gnss_hgt_bias_published{}; - uint16_t _gnss_failed_checks{0}; ///< failed checks of the latest vehicle_gnss sample, among those that decide usable - uORB::Subscription _vehicle_gnss_sub{ORB_ID(vehicle_gnss)}; uORB::PublicationMulti _estimator_gnss_hgt_bias_pub{ORB_ID(estimator_gnss_hgt_bias)}; diff --git a/src/modules/mavlink/streams/HIGH_LATENCY2.hpp b/src/modules/mavlink/streams/HIGH_LATENCY2.hpp index 8a7c718714a..f97742f7493 100644 --- a/src/modules/mavlink/streams/HIGH_LATENCY2.hpp +++ b/src/modules/mavlink/streams/HIGH_LATENCY2.hpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -291,6 +292,7 @@ private: if (_estimator_selector_status_sub.copy(&estimator_selector_status)) { if (estimator_selector_status.primary_instance != _estimator_status_sub.get_instance()) { _estimator_status_sub.ChangeInstance(estimator_selector_status.primary_instance); + _estimator_status_flags_sub.ChangeInstance(estimator_selector_status.primary_instance); } } } @@ -298,13 +300,17 @@ private: estimator_status_s estimator_status; if (_estimator_status_sub.update(&estimator_status)) { - if (estimator_status.gps_check_fail_flags > 0 || - estimator_status.filter_fault_flags > 0) { - + if (estimator_status.filter_fault_flags > 0) { msg->failure_flags |= HL_FAILURE_FLAG_ESTIMATOR; } - if (estimator_status.gps_check_fail_flags > 0) { + // The estimator intends to use GNSS, but the receiver stopped or delivers samples it can't use + estimator_status_flags_s estimator_status_flags; + + if (_estimator_status_flags_sub.copy(&estimator_status_flags) + && ((estimator_status_flags.gnss_fusion_state == estimator_status_flags_s::GNSS_FUSION_NO_DATA) + || (estimator_status_flags.gnss_fusion_state == estimator_status_flags_s::GNSS_FUSION_UNUSABLE) + || (estimator_status_flags.gnss_fusion_state == estimator_status_flags_s::GNSS_FUSION_VEL_LIMIT))) { msg->failure_flags |= HL_FAILURE_FLAG_GPS; } @@ -667,6 +673,7 @@ private: uORB::Subscription _attitude_sp_sub{ORB_ID(vehicle_attitude_setpoint)}; uORB::Subscription _estimator_selector_status_sub{ORB_ID(estimator_selector_status)}; uORB::Subscription _estimator_status_sub{ORB_ID(estimator_status)}; + uORB::Subscription _estimator_status_flags_sub{ORB_ID(estimator_status_flags)}; uORB::Subscription _pos_ctrl_status_sub{ORB_ID(position_controller_status)}; uORB::Subscription _geofence_sub{ORB_ID(geofence_result)}; uORB::Subscription _global_pos_sub{ORB_ID(vehicle_global_position)};