Skip to content

Commit 01d0b88

Browse files
committed
commander: report GNSS yaw fault to user
1 parent 44219e9 commit 01d0b88

File tree

9 files changed

+20
-5
lines changed

9 files changed

+20
-5
lines changed

msg/estimator_event_flags.msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ bool bad_yaw_using_gps_course # 7 - true when the fiter has detected
3030
bool stopping_mag_use # 8 - true when the filter has detected bad magnetometer data and is stopping further use of the magnetomer data
3131
bool vision_data_stopped # 9 - true when the vision system data has stopped for a significant time period
3232
bool emergency_yaw_reset_mag_stopped # 10 - true when the filter has detected bad magnetometer data, has reset the yaw to anothter source of data and has stopped further use of the magnetomer data
33+
bool emergency_yaw_reset_gps_yaw_stopped # 11 - true when the filter has detected bad GNSS yaw data, has reset the yaw to anothter source of data and has stopped further use of the GNSS yaw data

msg/estimator_status.msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ uint8 CS_GND_EFFECT = 20 # 20 - true when when protection from ground effect ind
4646
uint8 CS_RNG_STUCK = 21 # 21 - true when a stuck range finder sensor has been detected
4747
uint8 CS_GPS_YAW = 22 # 22 - true when yaw (not ground course) data from a GPS receiver is being fused
4848
uint8 CS_MAG_ALIGNED = 23 # 23 - true when the in-flight mag field alignment has been completed
49+
uint8 CS_EV_VEL = 24 # 24 - true when local frame velocity data fusion from external vision measurements is intended
50+
uint8 CS_SYNTHETIC_MAG_Z = 25 # 25 - true when we are using a synthesized measurement for the magnetometer Z component
51+
uint8 CS_VEHICLE_AT_REST = 26 # 26 - true when the vehicle is at rest
52+
uint8 CS_GPS_YAW_FAULT = 27 # 27 - true when the GNSS heading has been declared faulty and is no longer being used
4953

5054
uint32 filter_fault_flags # Bitmask to indicate EKF internal faults
5155
# 0 - true if the fusion of the magnetometer X-axis has encountered a numerical error

msg/estimator_status_flags.msg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ bool cs_mag_aligned_in_flight # 23 - true when the in-flight mag field alignment
3131
bool cs_ev_vel # 24 - true when local frame velocity data fusion from external vision measurements is intended
3232
bool cs_synthetic_mag_z # 25 - true when we are using a synthesized measurement for the magnetometer Z component
3333
bool cs_vehicle_at_rest # 26 - true when the vehicle is at rest
34-
34+
bool cs_gps_yaw_fault # 27 - true when the GNSS heading has been declared faulty and is no longer being used
3535

3636
# fault status
3737
uint32 fault_status_changes # number of filter fault status (fs) changes

src/modules/commander/Commander.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3786,6 +3786,8 @@ void Commander::estimator_check()
37863786
}
37873787

37883788
const bool mag_fault_prev = (_estimator_status_sub.get().control_mode_flags & (1 << estimator_status_s::CS_MAG_FAULT));
3789+
const bool gnss_heading_fault_prev = (_estimator_status_sub.get().control_mode_flags &
3790+
(1 << estimator_status_s::CS_GPS_YAW_FAULT));
37893791

37903792
// use primary estimator_status
37913793
if (_estimator_selector_status_sub.updated()) {
@@ -3803,12 +3805,18 @@ void Commander::estimator_check()
38033805

38043806
// Check for a magnetomer fault and notify the user
38053807
const bool mag_fault = (estimator_status.control_mode_flags & (1 << estimator_status_s::CS_MAG_FAULT));
3808+
const bool gnss_heading_fault = (estimator_status.control_mode_flags & (1 << estimator_status_s::CS_GPS_YAW_FAULT));
38063809

38073810
if (!mag_fault_prev && mag_fault) {
38083811
mavlink_log_critical(&_mavlink_log_pub, "Stopping compass use! Check calibration on landing");
38093812
set_health_flags(subsystem_info_s::SUBSYSTEM_TYPE_MAG, true, true, false, _status);
38103813
}
38113814

3815+
if (!gnss_heading_fault_prev && gnss_heading_fault) {
3816+
mavlink_log_critical(&_mavlink_log_pub, "Stopping GNSS heading use! Check configuration on landing");
3817+
set_health_flags(subsystem_info_s::SUBSYSTEM_TYPE_GPS, true, true, false, _status);
3818+
}
3819+
38123820
/* Check estimator status for signs of bad yaw induced post takeoff navigation failure
38133821
* for a short time interval after takeoff.
38143822
* Most of the time, the drone can recover from a bad initial yaw using GPS-inertial

src/modules/ekf2/EKF/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ union filter_control_status_u {
487487
uint32_t ev_vel : 1; ///< 24 - true when local frame velocity data fusion from external vision measurements is intended
488488
uint32_t synthetic_mag_z : 1; ///< 25 - true when we are using a synthesized measurement for the magnetometer Z component
489489
uint32_t vehicle_at_rest : 1; ///< 26 - true when the vehicle is at rest
490+
uint32_t gps_yaw_fault : 1; ///< 27 - true when the GNSS heading has been declared faulty and is no longer being used
490491
} flags;
491492
uint32_t value;
492493
};

src/modules/ekf2/EKF/control.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ void Ekf::controlGpsFusion()
751751
void Ekf::controlGpsYawFusion(bool gps_checks_passing, bool gps_checks_failing)
752752
{
753753
if (!(_params.fusion_mode & MASK_USE_GPSYAW)
754-
|| _is_gps_yaw_faulty) {
754+
|| _control_status.flags.gps_yaw_fault) {
755755

756756
stopGpsYawFusion();
757757
return;
@@ -793,7 +793,7 @@ void Ekf::controlGpsYawFusion(bool gps_checks_passing, bool gps_checks_failing)
793793
} else if (starting_conditions_passing) {
794794
// Data seems good, but previous reset did not fix the issue
795795
// something else must be wrong, declare the sensor faulty and stop the fusion
796-
_is_gps_yaw_faulty = true;
796+
_control_status.flags.gps_yaw_fault = true;
797797
stopGpsYawFusion();
798798

799799
} else {

src/modules/ekf2/EKF/ekf.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,6 @@ class Ekf final : public EstimatorInterface
536536
// height sensor status
537537
bool _baro_hgt_faulty{false}; ///< true if valid baro data is unavailable for use
538538
bool _gps_hgt_intermittent{false}; ///< true if gps height into the buffer is intermittent
539-
bool _is_gps_yaw_faulty{false}; ///< true if gps yaw data is rejected by the filter for too long
540539

541540
// imu fault status
542541
uint64_t _time_bad_vert_accel{0}; ///< last time a bad vertical accel was detected (uSec)

src/modules/ekf2/EKF/ekf_helper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,7 @@ bool Ekf::resetYawToEKFGSF()
16981698
_warning_events.flags.emergency_yaw_reset_mag_stopped = true;
16991699

17001700
} else if (_control_status.flags.gps_yaw) {
1701-
_is_gps_yaw_faulty = true;
1701+
_control_status.flags.gps_yaw_fault = true;
17021702
_warning_events.flags.emergency_yaw_reset_gps_yaw_stopped = true;
17031703

17041704
} else if (_control_status.flags.ev_yaw) {

src/modules/ekf2/EKF2.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ void EKF2::PublishEventFlags(const hrt_abstime &timestamp)
641641
event_flags.stopping_mag_use = _ekf.warning_event_flags().stopping_mag_use;
642642
event_flags.vision_data_stopped = _ekf.warning_event_flags().vision_data_stopped;
643643
event_flags.emergency_yaw_reset_mag_stopped = _ekf.warning_event_flags().emergency_yaw_reset_mag_stopped;
644+
event_flags.emergency_yaw_reset_gps_yaw_stopped = _ekf.warning_event_flags().emergency_yaw_reset_gps_yaw_stopped;
644645

645646
event_flags.timestamp = _replay_mode ? timestamp : hrt_absolute_time();
646647
_estimator_event_flags_pub.publish(event_flags);
@@ -1172,6 +1173,7 @@ void EKF2::PublishStatusFlags(const hrt_abstime &timestamp)
11721173
status_flags.cs_ev_vel = _ekf.control_status_flags().ev_vel;
11731174
status_flags.cs_synthetic_mag_z = _ekf.control_status_flags().synthetic_mag_z;
11741175
status_flags.cs_vehicle_at_rest = _ekf.control_status_flags().vehicle_at_rest;
1176+
status_flags.cs_gps_yaw_fault = _ekf.control_status_flags().gps_yaw_fault;
11751177

11761178
status_flags.fault_status_changes = _filter_fault_status_changes;
11771179
status_flags.fs_bad_mag_x = _ekf.fault_status_flags().bad_mag_x;

0 commit comments

Comments
 (0)