From 11df8168ee1adb410a5a5d0240535eb1d0b41cf3 Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 13 Feb 2016 08:56:25 +0100 Subject: [PATCH] provide ekf2 with landed flag from landing detector --- src/lib/ecl | 2 +- src/modules/ekf2/ekf2_main.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib/ecl b/src/lib/ecl index ce0ddc0207..ad978c642f 160000 --- a/src/lib/ecl +++ b/src/lib/ecl @@ -1 +1 @@ -Subproject commit ce0ddc02078ff96c5be31f958e515408d158f8aa +Subproject commit ad978c642ff6f2be06fe8dd29693983e6e216779 diff --git a/src/modules/ekf2/ekf2_main.cpp b/src/modules/ekf2/ekf2_main.cpp index 8cf2b0e8bb..5aa9a39018 100644 --- a/src/modules/ekf2/ekf2_main.cpp +++ b/src/modules/ekf2/ekf2_main.cpp @@ -75,6 +75,7 @@ #include #include #include +#include #include @@ -128,6 +129,7 @@ private: int _airspeed_sub = -1; int _params_sub = -1; int _control_mode_sub = -1; + int _vehicle_status_sub = -1; orb_advert_t _att_pub; orb_advert_t _lpos_pub; @@ -253,6 +255,7 @@ void Ekf2::task_main() _airspeed_sub = orb_subscribe(ORB_ID(airspeed)); _params_sub = orb_subscribe(ORB_ID(parameter_update)); _control_mode_sub = orb_subscribe(ORB_ID(vehicle_control_mode)); + _vehicle_status_sub = orb_subscribe(ORB_ID(vehicle_status)); px4_pollfd_struct_t fds[2] = {}; fds[0].fd = _sensors_sub; @@ -295,6 +298,7 @@ void Ekf2::task_main() bool gps_updated = false; bool airspeed_updated = false; bool control_mode_updated = false; + bool vehicle_status_updated = false; sensor_combined_s sensors = {}; airspeed_s airspeed = {}; @@ -364,6 +368,15 @@ void Ekf2::task_main() _ekf->setAirspeedData(airspeed.timestamp, &airspeed.indicated_airspeed_m_s); } + // read vehicle status if available for 'landed' information + orb_check(_vehicle_status_sub, &vehicle_status_updated); + + if (vehicle_status_updated) { + struct vehicle_status_s status = {}; + orb_copy(ORB_ID(vehicle_status), _vehicle_status_sub, &status); + _ekf->set_in_air_status(!status.condition_landed); + } + // run the EKF update _ekf->update();