diff --git a/libraries/AP_NavEKF2/AP_NavEKF2.cpp b/libraries/AP_NavEKF2/AP_NavEKF2.cpp index 9d0da3371f..cd8f3f78a7 100644 --- a/libraries/AP_NavEKF2/AP_NavEKF2.cpp +++ b/libraries/AP_NavEKF2/AP_NavEKF2.cpp @@ -940,6 +940,15 @@ void NavEKF2::getInnovations(int8_t instance, Vector3f &velInnov, Vector3f &posI } } +// publish output observer angular, velocity and position tracking error +void NavEKF2::getOutputTrackingError(int8_t instance, Vector3f &error) const +{ + if (instance < 0 || instance >= num_cores) instance = primary; + if (core) { + core[instance].getOutputTrackingError(error); + } +} + // return the innovation consistency test ratios for the velocity, position, magnetometer and true airspeed measurements void NavEKF2::getVariances(int8_t instance, float &velVar, float &posVar, float &hgtVar, Vector3f &magVar, float &tasVar, Vector2f &offset) { diff --git a/libraries/AP_NavEKF2/AP_NavEKF2.h b/libraries/AP_NavEKF2/AP_NavEKF2.h index ca93c9c0b6..1485695bc4 100644 --- a/libraries/AP_NavEKF2/AP_NavEKF2.h +++ b/libraries/AP_NavEKF2/AP_NavEKF2.h @@ -174,6 +174,9 @@ public: // An out of range instance (eg -1) returns data for the the primary instance void getInnovations(int8_t index, Vector3f &velInnov, Vector3f &posInnov, Vector3f &magInnov, float &tasInnov, float &yawInnov); + // publish output observer angular, velocity and position tracking error + void getOutputTrackingError(int8_t instance, Vector3f &error) const; + // return the innovation consistency test ratios for the specified instance // An out of range instance (eg -1) returns data for the the primary instance void getVariances(int8_t instance, float &velVar, float &posVar, float &hgtVar, Vector3f &magVar, float &tasVar, Vector2f &offset); diff --git a/libraries/AP_NavEKF2/AP_NavEKF2_Outputs.cpp b/libraries/AP_NavEKF2/AP_NavEKF2_Outputs.cpp index 52b1fba3cc..1249c5f16e 100644 --- a/libraries/AP_NavEKF2/AP_NavEKF2_Outputs.cpp +++ b/libraries/AP_NavEKF2/AP_NavEKF2_Outputs.cpp @@ -578,4 +578,10 @@ uint8_t NavEKF2_core::getFramesSincePredict(void) const return framesSincePredict; } +// publish output observer angular, velocity and position tracking error +void NavEKF2_core::getOutputTrackingError(Vector3f &error) const +{ + error = outputTrackError; +} + #endif // HAL_CPU_CLASS diff --git a/libraries/AP_NavEKF2/AP_NavEKF2_core.h b/libraries/AP_NavEKF2/AP_NavEKF2_core.h index a22bf1e3df..dc668a914e 100644 --- a/libraries/AP_NavEKF2/AP_NavEKF2_core.h +++ b/libraries/AP_NavEKF2/AP_NavEKF2_core.h @@ -258,6 +258,9 @@ public: // this is used by other instances to level load uint8_t getFramesSincePredict(void) const; + // publish output observer angular, velocity and position tracking error + void getOutputTrackingError(Vector3f &error) const; + private: // Reference to the global EKF frontend for parameters NavEKF2 *frontend; @@ -790,6 +793,8 @@ private: Vector3f delAngCorrected; // corrected IMU delta angle vector at the EKF time horizon (rad) Vector3f delVelCorrected; // corrected IMU delta velocity vector at the EKF time horizon (m/s) + Vector3f outputTrackError; + // variables used to calculate a vertical velocity that is kinematically consistent with the verical position float posDownDerivative; // Rate of chage of vertical position (dPosD/dt) in m/s. This is the first time derivative of PosD. float posDown; // Down position state used in calculation of posDownRate