AP_AHRS: add get_primary_core_index

This commit is contained in:
Randy Mackay 2020-04-21 13:39:45 +09:00
parent 6e93f54cff
commit 585c806618
3 changed files with 32 additions and 0 deletions

View File

@ -137,6 +137,9 @@ public:
return _airspeed;
}
// return the index of the primary core or -1 if no primary core selected
virtual int8_t get_primary_core_index() const { return -1; }
// get the index of the current primary accelerometer sensor
virtual uint8_t get_primary_accel_index(void) const {
return AP::ins().get_primary_accel();

View File

@ -2151,6 +2151,32 @@ const Vector3f &AP_AHRS_NavEKF::get_accel_ef() const
return get_accel_ef(get_primary_accel_index());
}
// return the index of the primary core or -1 if no primary core selected
int8_t AP_AHRS_NavEKF::get_primary_core_index() const
{
switch (active_EKF_type()) {
case EKFType::NONE:
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
case EKFType::SITL:
#endif
// SITL and DCM have only one core
return 0;
#if HAL_NAVEKF2_AVAILABLE
case EKFType::TWO:
return EKF2.getPrimaryCoreIndex();
#endif
#if HAL_NAVEKF3_AVAILABLE
case EKFType::THREE:
return EKF3.getPrimaryCoreIndex();
#endif
}
// we should never get here
AP::internalerror().error(AP_InternalError::error_t::flow_of_control);
return -1;
}
// get the index of the current primary accelerometer sensor
uint8_t AP_AHRS_NavEKF::get_primary_accel_index(void) const

View File

@ -278,6 +278,9 @@ public:
// is the EKF backend doing its own sensor logging?
bool have_ekf_logging(void) const override;
// return the index of the primary core or -1 if no primary core selected
int8_t get_primary_core_index() const override;
// get the index of the current primary accelerometer sensor
uint8_t get_primary_accel_index(void) const override;