AP_Compass: added get_num_enabled()

used by EKF3
This commit is contained in:
Andrew Tridgell 2020-05-09 09:46:59 +10:00
parent 9eaf7f5528
commit 4a80313fdd
2 changed files with 21 additions and 0 deletions

View File

@ -1478,6 +1478,24 @@ Compass::use_for_yaw(uint8_t i) const
return _use_for_yaw[Priority(i)] && _learn.get() != LEARN_INFLIGHT; return _use_for_yaw[Priority(i)] && _learn.get() != LEARN_INFLIGHT;
} }
/*
return the number of enabled sensors. Used to determine if
non-compass operation is desired
*/
uint8_t Compass::get_num_enabled(void) const
{
if (get_count() == 0) {
return 0;
}
uint8_t count = 0;
for (uint8_t i=0; i<COMPASS_MAX_INSTANCES; i++) {
if (use_for_yaw(i)) {
count++;
}
}
return count;
}
void void
Compass::set_use_for_yaw(uint8_t i, bool use) Compass::set_use_for_yaw(uint8_t i, bool use)
{ {

View File

@ -137,6 +137,9 @@ public:
// return the number of compass instances // return the number of compass instances
uint8_t get_count(void) const { return _compass_count; } uint8_t get_count(void) const { return _compass_count; }
// return the number of enabled sensors
uint8_t get_num_enabled(void) const;
/// Return the current field as a Vector3f in milligauss /// Return the current field as a Vector3f in milligauss
const Vector3f &get_field(uint8_t i) const { return _get_state(Priority(i)).field; } const Vector3f &get_field(uint8_t i) const { return _get_state(Priority(i)).field; }
const Vector3f &get_field(void) const { return get_field(0); } const Vector3f &get_field(void) const { return get_field(0); }