From c3a015103436c59b00770bbcb5ff5e4e075c148f Mon Sep 17 00:00:00 2001 From: Hannes Diethelm Date: Thu, 18 Oct 2018 20:03:59 +0200 Subject: [PATCH 1/2] Fix landed detection --- example/offboard_velocity/offboard_velocity.cpp | 11 +++++++++-- example/takeoff_land/takeoff_and_land.cpp | 10 +++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/example/offboard_velocity/offboard_velocity.cpp b/example/offboard_velocity/offboard_velocity.cpp index e65f9f7c7f..9d51e5ad11 100644 --- a/example/offboard_velocity/offboard_velocity.cpp +++ b/example/offboard_velocity/offboard_velocity.cpp @@ -237,9 +237,16 @@ int main(int argc, char **argv) const Action::Result land_result = action->land(); action_error_exit(land_result, "Landing failed"); + // Check if vehicle is still in air + while (telemetry->in_air() == true) { + std::cout << "Vehicle is landing..." << std::endl; + sleep_for(seconds(1)); + } + std::cout << "Landed!" << std::endl; + // We are relying on auto-disarming but let's keep watching the telemetry for a bit longer. - sleep_for(seconds(10)); - std::cout << "Landed" << std::endl; + sleep_for(seconds(3)); + std::cout << "Finished..." << std::endl; return EXIT_SUCCESS; } diff --git a/example/takeoff_land/takeoff_and_land.cpp b/example/takeoff_land/takeoff_and_land.cpp index ad7ef3b89f..07760611c8 100644 --- a/example/takeoff_land/takeoff_and_land.cpp +++ b/example/takeoff_land/takeoff_and_land.cpp @@ -139,8 +139,16 @@ int main(int argc, char **argv) return 1; } + // Check if vehicle is still in air + while (telemetry->in_air() == true) { + std::cout << "Vehicle is landing..." << std::endl; + sleep_for(seconds(1)); + } + std::cout << "Landed!" << std::endl; + // We are relying on auto-disarming but let's keep watching the telemetry for a bit longer. - sleep_for(seconds(5)); + sleep_for(seconds(3)); std::cout << "Finished..." << std::endl; + return 0; } From a5d1e16722d0c7c2d44603c9a23f7d15573781a4 Mon Sep 17 00:00:00 2001 From: Hannes Diethelm Date: Fri, 19 Oct 2018 10:15:22 +0200 Subject: [PATCH 2/2] Remove == true --- example/offboard_velocity/offboard_velocity.cpp | 2 +- example/takeoff_land/takeoff_and_land.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example/offboard_velocity/offboard_velocity.cpp b/example/offboard_velocity/offboard_velocity.cpp index 9d51e5ad11..aaf10f3078 100644 --- a/example/offboard_velocity/offboard_velocity.cpp +++ b/example/offboard_velocity/offboard_velocity.cpp @@ -238,7 +238,7 @@ int main(int argc, char **argv) action_error_exit(land_result, "Landing failed"); // Check if vehicle is still in air - while (telemetry->in_air() == true) { + while (telemetry->in_air()) { std::cout << "Vehicle is landing..." << std::endl; sleep_for(seconds(1)); } diff --git a/example/takeoff_land/takeoff_and_land.cpp b/example/takeoff_land/takeoff_and_land.cpp index 07760611c8..848691f62e 100644 --- a/example/takeoff_land/takeoff_and_land.cpp +++ b/example/takeoff_land/takeoff_and_land.cpp @@ -140,7 +140,7 @@ int main(int argc, char **argv) } // Check if vehicle is still in air - while (telemetry->in_air() == true) { + while (telemetry->in_air()) { std::cout << "Vehicle is landing..." << std::endl; sleep_for(seconds(1)); }