From 21f7641e8d71505252c07a59c89089dcfa484388 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 12 Jan 2016 07:32:38 +0100 Subject: [PATCH] log ekf2 estimator status --- src/modules/ekf2/ekf2_main.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/modules/ekf2/ekf2_main.cpp b/src/modules/ekf2/ekf2_main.cpp index a0eb643cb4..2c84e714d2 100644 --- a/src/modules/ekf2/ekf2_main.cpp +++ b/src/modules/ekf2/ekf2_main.cpp @@ -72,6 +72,7 @@ #include #include #include +#include #include @@ -131,6 +132,8 @@ private: orb_advert_t _lpos_pub; orb_advert_t _control_state_pub; orb_advert_t _vehicle_global_position_pub; + orb_advert_t _estimator_status_pub; + /* Low pass filter for attitude rates */ math::LowPassFilter2p _lp_roll_rate; @@ -174,12 +177,12 @@ Ekf2::Ekf2(): _lpos_pub(nullptr), _control_state_pub(nullptr), _vehicle_global_position_pub(nullptr), + _estimator_status_pub(nullptr), _lp_roll_rate(250.0f, 30.0f), _lp_pitch_rate(250.0f, 30.0f), _lp_yaw_rate(250.0f, 20.0f), _ekf(new Ekf()) { - parameters *params = _ekf->getParamHandle(); _mag_delay_ms = new control::BlockParamFloat(this, "EKF2_MAG_DELAY", false, ¶ms->mag_delay_ms); _baro_delay_ms = new control::BlockParamFloat(this, "EKF2_BARO_DELAY", false, ¶ms->baro_delay_ms); @@ -474,6 +477,19 @@ void Ekf2::task_main() orb_publish(ORB_ID(vehicle_global_position), _vehicle_global_position_pub, &global_pos); } } + + // publish estimator status + struct estimator_status_s status = {}; + status.timestamp = hrt_absolute_time(); + _ekf->get_state_delayed(status.states); + _ekf->get_covariances(status.covariances); + + if (_estimator_status_pub == nullptr) { + _estimator_status_pub = orb_advertise(ORB_ID(estimator_status), &status); + + } else { + orb_publish(ORB_ID(estimator_status), _estimator_status_pub, &status); + } } delete ekf2::instance;