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

GPS preflight check: improve reporting #10586

Merged
merged 8 commits into from
Sep 29, 2018
Merged

GPS preflight check: improve reporting #10586

merged 8 commits into from
Sep 29, 2018

Conversation

bkueng
Copy link
Member

@bkueng bkueng commented Sep 27, 2018

Previously it was possible to get a Position Control rejected message without further advice what was actually wrong (the drone could even have a valid GPS position). So now we report warnings even if gps is not required for arming (which could be annoying too...).
The GPS failure message was very generic, making it hard to debug the cause. Now we check every bit and send an appropriate warning. EKF2 has threshold parameters for each of those checks.

All strings were checked not to exceed the maximum length of 50 characters.

Additional changes:

  • ekf2: only report gps failure flags that are enabled
  • PreflightChecks: improve labels in general by not capitalizing everything
  • mavlink_receiver: reduce s_variance_m_s for HIL GPS message from 1 to 0.1. This fixes position control for HIL not working.

… 0.1

1 was too high to pass the EKF2 test (EKF2_REQ_SACC which is 0.5 by default)
and thus switching into position mode in HIL was not possible.
So that they can be used for reporting errors.
LorenzMeier
LorenzMeier previously approved these changes Sep 27, 2018
@@ -113,7 +113,7 @@ static bool magnometerCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &sta

if (!mag_valid) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: MAG #%u invalid", instance);
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: Mag #%u invalid", instance);
Copy link
Member

Choose a reason for hiding this comment

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

What does "Mag invalid" mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed to Preflight Fail: no valid Data for Mag. Is that better?

Copy link
Member

Choose a reason for hiding this comment

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

Much better! Can you do it for accel/gyro too?

if (report_fail) {
// Only report the first failure to avoid spamming
if (status.gps_check_fail_flags & (1 << estimator_status_s::GPS_CHECK_FAIL_GPS_FIX)) {
mavlink_log_critical(mavlink_log_pub, "Preflight %s: GPS fix not too low", fail_str);
Copy link
Member

Choose a reason for hiding this comment

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

What does this mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ha, my fail. Fixed.

@dagar
Copy link
Member

dagar commented Sep 27, 2018

We should double check the QGC side. There was discussion of special handling for "PREFLIGHT" and "PREARM" messages previously.

@DonLakeFlyer

- previously it was possible to get a Position Control rejected message
  without further advice what was actually wrong. So now we report warnings
  even if gps is not required for arming (which could be annoying too...).
- the GPS failure message was very generic, making it hard to debug the
  cause. Now we check every bit and send an appropriate warning

All strings were checked not to exceed the maximum length of 50 characters.
@bkueng bkueng force-pushed the gps_preflight_cleanup branch from e600e7c to fd7dd79 Compare September 27, 2018 15:50
@bkueng
Copy link
Member Author

bkueng commented Sep 27, 2018

A quick QGC grep for PREFLIGHT did not reveal anything.

@dagar
Copy link
Member

dagar commented Sep 27, 2018

Two more points to think about for later.

  1. There are usability and safety issues in and around these requirements we should discuss at some point. For example if RTL is configured anywhere (failsafes for loss of RC, low battery, etc) perhaps we should require valid home and valid position for arming. Obviously we don't want to burden a user that intends to jump straight into a stabilized or altitude flight only, but the desired use case and implications need to be carefully thought through.

  2. The way these GPS checks are implemented makes the system dependant on EKF2 in a way that seems easily avoidable. Nearly all of these "estimator" GPS check bits are simply against the raw GPS data. https://github.com/PX4/ecl/blob/master/EKF/gps_checks.cpp#L110-L126 @priseborough Thoughts?

@dagar
Copy link
Member

dagar commented Sep 27, 2018

A quick QGC grep for PREFLIGHT did not reveal anything.

Looks like it's only "PreArm:" currently.
https://github.com/mavlink/qgroundcontrol/blob/master/src/QGCApplication.cc#L677-L680

@DonLakeFlyer @bkueng can we agree on what to do here? The way QGC handles "PreArm:" looks much nicer.

mavlink/qgroundcontrol#6436
mavlink/qgroundcontrol#3460


success = false;
goto out;
const char *fail_str = enforce_gps_required ? "Fail" : "Warn";
Copy link
Member

Choose a reason for hiding this comment

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

Let's use the existing mavlink severity levels instead.
https://mavlink.io/en/messages/common.html#MAV_SEVERITY

Copy link
Member

Choose a reason for hiding this comment

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

@DonLakeFlyer
Copy link
Contributor

FYI: The original pull which support the PreArm QGC thing was lost in the fray. The new one is here: mavlink/qgroundcontrol#6898 and could use some testing.

@Antiheavy
Copy link
Contributor

This is a great PR! Much needed improvements. I'll humbly submit some wording suggestions as comments in-line with the code. thanks!

@@ -113,7 +113,7 @@ static bool magnometerCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &sta

if (!mag_valid) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: MAG #%u invalid", instance);
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: no valid Data for Mag #%u", instance);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest: "Preflight Fail: no valid data from Mag #%u", or "Preflight Fail: invalid data from Mag #%u"

@@ -123,13 +123,13 @@ static bool magnometerCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &sta

if (!calibration_valid) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: MAG #%u UNCALIBRATED", instance);
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: Mag #%u uncalibrated", instance);
Copy link
Contributor

@Antiheavy Antiheavy Sep 28, 2018

Choose a reason for hiding this comment

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

The inconsistent use of the terms "Mag" and "Compass" can be confusing for users. In QGC you must go to the "Compass" calibration page to calibrate the Mag(s). This is a larger issue, so I guess I'm just making a comment more than suggesting a change here.

@@ -249,7 +249,7 @@ static bool accelerometerCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &

if (!accel_valid) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: ACCEL #%u invalid", instance);
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: no valid Data for Accel #%u", instance);
Copy link
Contributor

@Antiheavy Antiheavy Sep 28, 2018

Choose a reason for hiding this comment

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

suggest: "Preflight Fail: no valid data from Accel #%u" or "Preflight Fail: invalid data from Accel #%u"

@@ -313,7 +313,7 @@ static bool gyroCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &status, u

if (!gyro_valid) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: GYRO #%u invalid", instance);
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: no valid Data for Gyro #%u", instance);
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest: "Preflight Fail: no valid data from Gyro #%u" or "Preflight Fail: invalid data from Gyro #%u"

@@ -356,14 +356,14 @@ static bool baroCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &status, u

if (!baro_valid) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: BARO #%u invalid", instance);
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: no valid Data for Baro #%u", instance);
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest: "Preflight Fail: no valid data from Baro #%u" or "Preflight Fail: invalid data from Baro #%u"

@@ -389,7 +389,7 @@ static bool airspeedCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &statu
if ((orb_copy(ORB_ID(differential_pressure), fd_diffpres, &differential_pressure) != PX4_OK) ||
(hrt_elapsed_time(&differential_pressure.timestamp) > 1_s)) {
if (report_fail && !optional) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: AIRSPEED SENSOR MISSING");
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: Airspeed Sensor missing");
Copy link
Contributor

Choose a reason for hiding this comment

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

Couple comments here:

  1. this is the first use of "< > sensor missing". The other sensors print out "no < > sensor". From a user standpoint I like the "< > sensor missing" message better because it implies that the sensor is both expected to be there and also that it is missing. The meaning for "no < > sensor" message is a bit more vague. Either way, I think we should aim for consistency.
  2. can this be extended to support multiple diffpres/airspeed sensors?

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. Good point, I switched to the 'sensor missing' version.
  2. I don't know, it's probably a bigger thing.

Copy link
Member

Choose a reason for hiding this comment

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

  1. Yes it can and yes it's a slightly bigger thing.

@@ -400,7 +400,7 @@ static bool airspeedCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s &statu
if ((orb_copy(ORB_ID(airspeed), fd_airspeed, &airspeed) != PX4_OK) ||
(hrt_elapsed_time(&airspeed.timestamp) > 1_s)) {
if (report_fail && !optional) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: AIRSPEED SENSOR MISSING");
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: Airspeed Sensor missing");
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as I made in the "diffpres" section above. I'm also unclear as to why there are two of these, but I'll assume there is a good reason.

Copy link
Member

Choose a reason for hiding this comment

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

It goes back to the change that allowed airspeed to be < 0. The code is checking |differential_pressure|, but could now be updated to check airspeed only. I think we already have this in a branch somewhere...

@@ -518,7 +518,7 @@ static bool ekf2Check(orb_advert_t *mavlink_log_pub, vehicle_status_s &vehicle_s
// Check if preflight check performed by estimator has failed
if (status.pre_flt_fail) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: EKF INTERNAL CHECKS");
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: EKF internal checks");
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this even mean? Can this message be written more specifically and in a way to be understood by the average user?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's one that I would like to get rid of as well. @priseborough ?

Copy link
Member

Choose a reason for hiding this comment

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

Let's remove or re-write the language.

Copy link
Member

Choose a reason for hiding this comment

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

"Preflight fail: Position unknown" or something like that.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed it to Position unknown.

@@ -530,7 +530,7 @@ static bool ekf2Check(orb_advert_t *mavlink_log_pub, vehicle_status_s &vehicle_s

if (status.hgt_test_ratio > test_limit) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: EKF HGT ERROR");
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: EKF Height Error");
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment applies to all the messages that contain "EKF":

  1. the average user has no clue what an EKF is. They are very confused by these messages.
  2. the term "EKF" doesn't add any helpful information to any of these messages anyway.
  3. Suggest: "Preflight Fail: Height estimate error"

@@ -542,7 +542,7 @@ static bool ekf2Check(orb_advert_t *mavlink_log_pub, vehicle_status_s &vehicle_s

if (status.vel_test_ratio > test_limit) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: EKF VEL ERROR");
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: EKF Velocity Error");
Copy link
Contributor

@Antiheavy Antiheavy Sep 28, 2018

Choose a reason for hiding this comment

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

suggest: "Preflight Fail: Velocity estimate error" or "Preflight Fail: Velocity error"

@@ -554,7 +554,7 @@ static bool ekf2Check(orb_advert_t *mavlink_log_pub, vehicle_status_s &vehicle_s

if (status.pos_test_ratio > test_limit) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: EKF HORIZ POS ERROR");
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: EKF Horizontal Position Error");
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest: "Preflight Fail: Horizontal position error"

@@ -566,7 +566,7 @@ static bool ekf2Check(orb_advert_t *mavlink_log_pub, vehicle_status_s &vehicle_s

if (status.mag_test_ratio > test_limit) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: EKF YAW ERROR");
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: EKF Yaw Error");
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest: "Preflight Fail: Yaw error"

@@ -579,7 +579,7 @@ static bool ekf2Check(orb_advert_t *mavlink_log_pub, vehicle_status_s &vehicle_s
if (fabsf(status.states[13]) > test_limit || fabsf(status.states[14]) > test_limit
|| fabsf(status.states[15]) > test_limit) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: EKF HIGH IMU ACCEL BIAS");
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: EKF High IMU Accel Bias");
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest: "Preflight Fail: High Accelerometer Bias"

@@ -592,55 +592,59 @@ static bool ekf2Check(orb_advert_t *mavlink_log_pub, vehicle_status_s &vehicle_s
if (fabsf(status.states[10]) > test_limit || fabsf(status.states[11]) > test_limit
|| fabsf(status.states[12]) > test_limit) {
if (report_fail) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: EKF HIGH IMU GYRO BIAS");
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: EKF High IMU Gyro Bias");
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest: "Preflight Fail: High Gyro Bias"

} else {
if (!ekf_gps_fusion) {
// Likely cause unknown
mavlink_log_critical(mavlink_log_pub, "Preflight %s: EKF not using GPS", fail_str);
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment that most users are confused by the term "EKF".
Suggest: "Preflight %s: System not using GPS"

@bkueng
Copy link
Member Author

bkueng commented Sep 28, 2018

Thanks @Antiheavy, great feedback. I think I incorperated all of it.

I updated the PR to use the correct log level, and I think it's good now.

Long-term the goal is to use the events interface for that.

@@ -223,7 +223,7 @@ static bool magConsistencyCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s

if (sensors.mag_inconsistency_ga > test_limit) {
if (report_status) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: MAG SENSORS INCONSISTENT");
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: Compass Sensors inconsistent");
Copy link
Member

Choose a reason for hiding this comment

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

Compass Sensors?

Copy link
Contributor

Choose a reason for hiding this comment

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

From a user perspective I think "Compass Sensors inconsistent" is more easily understood and more consistent with the user interface in QGC. However, "Mag" and "Mag Sensor(s)" is still used in some of the other warnings.

On a side note: I think it is still okay if "MAG" is used in the parameters and other developer and integrator focused areas. In user focused areas (UX and non-developer documentation) "compass" is more easily understood.

Copy link
Member

@dagar dagar Sep 28, 2018

Choose a reason for hiding this comment

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

Compass instead of Mag seems better to me as long as we're consistent everywhere. Compass Sensors is what I was questioning that seemed inconsistent with other messages.

Copy link
Contributor

Choose a reason for hiding this comment

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

So which is better: "Preflight Fail: Compass inconsistent" or "Preflight Fail: Compasses inconsistent"?

}
}

} else {
if (!optional && report_fail) {
mavlink_log_critical(mavlink_log_pub, "PREFLIGHT FAIL: NO MAG SENSOR #%u", instance);
mavlink_log_critical(mavlink_log_pub, "Preflight Fail: Compass Sensor #%u missing", instance);
Copy link
Contributor

@Antiheavy Antiheavy Sep 28, 2018

Choose a reason for hiding this comment

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

Edit: nevermind for consistency with other messages suggest using: "Preflight Fail: Compass #%u missing"

@dagar
Copy link
Member

dagar commented Sep 29, 2018

I'll merge this now and we can continue with any additional suggestions in another pull request or issue.

@dagar dagar merged commit df9a09c into master Sep 29, 2018
@dagar dagar deleted the gps_preflight_cleanup branch September 29, 2018 13:17
@bkueng bkueng mentioned this pull request Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants