-
Notifications
You must be signed in to change notification settings - Fork 16.8k
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
Plane to use AHRS_WIND_MAX as documented #10243
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a9e2314
AP_AHRS: Added get_max_wind to make it available for use in determini…
ChrisBird d3fbe38
AP_Airspeed: This adds the ability to turn off and on the airspeed se…
ChrisBird d324807
AP_Airspeed: convert the defines into static consts
magicrub 2da5f01
AP_Airspeed: Renaming the check method name and readding the overall …
ChrisBird 4413212
AP_Airspeed: log health failure probability
magicrub bce2cc5
AP_Logger: log health failure probability
magicrub File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#include <AP_Common/AP_Common.h> | ||
#include <GCS_MAVLink/GCS.h> | ||
#include <AP_Math/AP_Math.h> | ||
#include "AP_Airspeed.h" | ||
|
||
void AP_Airspeed::check_sensor_failures() | ||
{ | ||
for (uint8_t i=0; i<AIRSPEED_MAX_SENSORS; i++) { | ||
check_sensor_ahrs_wind_max_failures(i); | ||
} | ||
} | ||
|
||
void AP_Airspeed::check_sensor_ahrs_wind_max_failures(uint8_t i) | ||
{ | ||
const uint32_t now_ms = AP_HAL::millis(); | ||
if ((now_ms - state[i].failures.last_check_ms) <= 200) { | ||
// slow the checking rate | ||
return; | ||
} | ||
|
||
const float aspeed = get_airspeed(); | ||
const float wind_max = AP::ahrs().get_max_wind(); | ||
|
||
if (aspeed <= 0 || wind_max <= 0) { | ||
// invalid estimates | ||
return; | ||
} | ||
|
||
state[i].failures.last_check_ms = now_ms; | ||
|
||
// update state[i].failures.health_probability via LowPassFilter | ||
float speed_accuracy; | ||
if (AP::gps().speed_accuracy(speed_accuracy)) { | ||
const float gnd_speed = AP::gps().ground_speed(); | ||
|
||
if (aspeed > (gnd_speed + wind_max) || aspeed < (gnd_speed - wind_max)) { | ||
// bad, decay fast | ||
const float probability_coeff = 0.90f; | ||
//state[i].failures.health_probability = probability_coeff*state[i].failures.health_probability + (1.0f-probability_coeff)*0.0f; | ||
state[i].failures.health_probability = probability_coeff*state[i].failures.health_probability; // equivalent | ||
|
||
} else if (aspeed < (gnd_speed + wind_max) && aspeed > (gnd_speed - wind_max)) { | ||
// good, grow slow | ||
const float probability_coeff = 0.98f; | ||
state[i].failures.health_probability = probability_coeff*state[i].failures.health_probability + (1.0f-probability_coeff)*1.0f; | ||
} | ||
} | ||
|
||
|
||
// Now check if we need to disable or enable the sensor | ||
|
||
// here are some probability thresholds | ||
static const float DISABLE_PROB_THRESH_CRIT = 0.1f; | ||
static const float DISABLE_PROB_THRESH_WARN = 0.5f; | ||
static const float RE_ENABLE_PROB_THRESH_OK = 0.95f; | ||
|
||
// if "disable" option is allowed and sensor is enabled | ||
if (param[i].use > 0 && (AP_Airspeed::OptionsMask::ON_FAILURE_AHRS_WIND_MAX_DO_DISABLE & _options)) { | ||
// and is probably not healthy | ||
if (state[i].failures.health_probability < DISABLE_PROB_THRESH_CRIT) { | ||
gcs().send_text(MAV_SEVERITY_ERROR, "Airspeed sensor %d failure. Disabling", i+1); | ||
state[i].failures.param_use_backup = param[i].use; | ||
param[i].use.set_and_notify(0); | ||
state[i].healthy = false; | ||
|
||
// and is probably getting close to not healthy | ||
} else if ((state[i].failures.health_probability < DISABLE_PROB_THRESH_WARN) && !state[i].failures.has_warned) { | ||
state[i].failures.has_warned = true; | ||
gcs().send_text(MAV_SEVERITY_WARNING, "Airspeed sensor %d warning", i+1); | ||
|
||
} else if (state[i].failures.health_probability > RE_ENABLE_PROB_THRESH_OK) { | ||
state[i].failures.has_warned = false; | ||
} | ||
|
||
// if Re-Enable options is allowed, and sensor is disabled but was previously enabled, and is probably healthy | ||
} else if (param[i].use == 0 && | ||
(AP_Airspeed::OptionsMask::ON_FAILURE_AHRS_WIND_MAX_RECOVERY_DO_REENABLE & _options) && | ||
state[i].failures.param_use_backup > 0 && | ||
state[i].failures.health_probability > RE_ENABLE_PROB_THRESH_OK) { | ||
|
||
gcs().send_text(MAV_SEVERITY_NOTICE, "Airspeed sensor %d now OK. Re-enabled", i+1); | ||
param[i].use.set_and_notify(state[i].failures.param_use_backup); // resume | ||
state[i].failures.param_use_backup = -1; // set to invalid so we don't use it | ||
state[i].failures.has_warned = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is documented elsewhere, but would be nice to mention the units are in m/s like the other functions here are doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure no probs