From 968259e1b28d5fdf3e003b0547be24b229785dba Mon Sep 17 00:00:00 2001 From: Antonio Date: Sun, 27 Aug 2023 12:07:48 +0200 Subject: [PATCH] fixed landing --- .../src/real-robot/mavsdk/vpRobotMavsdk.cpp | 43 ++++++++----------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/modules/robot/src/real-robot/mavsdk/vpRobotMavsdk.cpp b/modules/robot/src/real-robot/mavsdk/vpRobotMavsdk.cpp index 924a2b5f99..dc8e5b943a 100644 --- a/modules/robot/src/real-robot/mavsdk/vpRobotMavsdk.cpp +++ b/modules/robot/src/real-robot/mavsdk/vpRobotMavsdk.cpp @@ -786,36 +786,29 @@ class vpRobotMavsdk::vpRobotMavsdkImpl } sleep_for(seconds(10)); - this->holdPosition(); - sleep_for(seconds(1)); - this->kill(); - return true; - - } else { - if (m_telemetry.get()->flight_mode() != mavsdk::Telemetry::FlightMode::Land) { - std::cout << "Landing...\n"; - const mavsdk::Action::Result land_result = m_action.get()->land(); - if (land_result != mavsdk::Action::Result::Success) { - std::cerr << "Land failed: " << land_result << std::endl; - return false; - } + } - // Check if vehicle is still in air - while (m_telemetry.get()->in_air()) { - std::cout << "Vehicle is landing..." << std::endl; - sleep_for(seconds(1)); - } + if (m_telemetry.get()->flight_mode() != mavsdk::Telemetry::FlightMode::Land) { + std::cout << "Landing...\n"; + const mavsdk::Action::Result land_result = m_action.get()->land(); + if (land_result != mavsdk::Action::Result::Success) { + std::cerr << "Land failed: " << land_result << std::endl; + return false; } - 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)); - std::cout << "Finished..." << std::endl; - return true; + // Check if vehicle is still in air + while (m_telemetry.get()->in_air()) { + std::cout << "Vehicle is landing..." << std::endl; + sleep_for(seconds(1)); + } } - return false; + 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)); + std::cout << "Finished..." << std::endl; + return true; } bool setPosition(float ned_north, float ned_east, float ned_down, float ned_yaw, bool blocking, int timeout_sec)