AP_AHRS: add a singleton-getter cast into AP_AHRS_NavEKF

This will allow libraries which absolutely require the EKF to easily get
a cast copy of the singleton.
This commit is contained in:
Peter Barker 2018-04-06 22:17:04 +10:00 committed by Francisco Ferreira
parent c83ff0e156
commit 4d944da530
2 changed files with 12 additions and 0 deletions

View File

@ -686,4 +686,10 @@ private:
namespace AP {
AP_AHRS &ahrs();
// use ahrs_navekf() only where the AHRS interface doesn't expose the
// functionality you require:
#if AP_AHRS_NAVEKF_AVAILABLE
AP_AHRS_NavEKF &ahrs_navekf();
#endif
};

View File

@ -1642,5 +1642,11 @@ uint8_t AP_AHRS_NavEKF::get_primary_gyro_index(void) const
return AP::ins().get_primary_gyro();
}
AP_AHRS_NavEKF &AP::ahrs_navekf()
{
return static_cast<AP_AHRS_NavEKF&>(*AP_AHRS::get_singleton());
}
#endif // AP_AHRS_NAVEKF_AVAILABLE