From 3763cd45ab885640920c22f126c538f05c752d0c Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Sun, 26 Aug 2018 12:41:13 +0200 Subject: [PATCH] example: fix after ActionResult -> Action::Result --- example/fly_mission/fly_mission.cpp | 17 ++++----- example/fly_qgc_mission/fly_qgc_mission.cpp | 17 ++++----- example/follow_me/follow_me.cpp | 14 ++++---- .../offboard_velocity/offboard_velocity.cpp | 12 +++---- example/takeoff_land/takeoff_and_land.cpp | 18 +++++----- .../transition_vtol_fixed_wing.cpp | 36 +++++++++---------- 6 files changed, 58 insertions(+), 56 deletions(-) diff --git a/example/fly_mission/fly_mission.cpp b/example/fly_mission/fly_mission.cpp index d190d14624..a1845def55 100644 --- a/example/fly_mission/fly_mission.cpp +++ b/example/fly_mission/fly_mission.cpp @@ -32,7 +32,7 @@ using namespace std::chrono; // for seconds(), milliseconds() using namespace std::this_thread; // for sleep_for() // Handles Action's result -inline void handle_action_err_exit(ActionResult result, const std::string &message); +inline void handle_action_err_exit(Action::Result result, const std::string &message); // Handles Mission's result inline void handle_mission_err_exit(Mission::Result result, const std::string &message); // Handles Connection result @@ -189,7 +189,7 @@ int main(int argc, char **argv) } std::cout << "Arming..." << std::endl; - const ActionResult arm_result = action->arm(); + const Action::Result arm_result = action->arm(); handle_action_err_exit(arm_result, "Arm failed: "); std::cout << "Armed." << std::endl; @@ -265,9 +265,10 @@ int main(int argc, char **argv) { // We are done, and can do RTL to go home. std::cout << "Commanding RTL..." << std::endl; - const ActionResult result = action->return_to_launch(); - if (result != ActionResult::SUCCESS) { - std::cout << "Failed to command RTL (" << action_result_str(result) << ")" << std::endl; + const Action::Result result = action->return_to_launch(); + if (result != Action::Result::SUCCESS) { + std::cout << "Failed to command RTL (" << Action::result_str(result) << ")" + << std::endl; } else { std::cout << "Commanded RTL." << std::endl; } @@ -302,10 +303,10 @@ std::shared_ptr make_mission_item(double latitude_deg, return new_item; } -inline void handle_action_err_exit(ActionResult result, const std::string &message) +inline void handle_action_err_exit(Action::Result result, const std::string &message) { - if (result != ActionResult::SUCCESS) { - std::cerr << ERROR_CONSOLE_TEXT << message << action_result_str(result) + if (result != Action::Result::SUCCESS) { + std::cerr << ERROR_CONSOLE_TEXT << message << Action::result_str(result) << NORMAL_CONSOLE_TEXT << std::endl; exit(EXIT_FAILURE); } diff --git a/example/fly_qgc_mission/fly_qgc_mission.cpp b/example/fly_qgc_mission/fly_qgc_mission.cpp index 3188c098f0..99755d59b8 100644 --- a/example/fly_qgc_mission/fly_qgc_mission.cpp +++ b/example/fly_qgc_mission/fly_qgc_mission.cpp @@ -42,7 +42,7 @@ using namespace std::chrono; // for seconds(), milliseconds() using namespace std::this_thread; // for sleep_for() // Handles Action's result -inline void handle_action_err_exit(ActionResult result, const std::string &message); +inline void handle_action_err_exit(Action::Result result, const std::string &message); // Handles Mission's result inline void handle_mission_err_exit(Mission::Result result, const std::string &message); // Handles Connection result @@ -144,7 +144,7 @@ int main(int argc, char **argv) } std::cout << "Arming..." << std::endl; - const ActionResult arm_result = action->arm(); + const Action::Result arm_result = action->arm(); handle_action_err_exit(arm_result, "Arm failed: "); std::cout << "Armed." << std::endl; @@ -176,9 +176,10 @@ int main(int argc, char **argv) { // Mission complete. Command RTL to go home. std::cout << "Commanding RTL..." << std::endl; - const ActionResult result = action->return_to_launch(); - if (result != ActionResult::SUCCESS) { - std::cout << "Failed to command RTL (" << action_result_str(result) << ")" << std::endl; + const Action::Result result = action->return_to_launch(); + if (result != Action::Result::SUCCESS) { + std::cout << "Failed to command RTL (" << Action::result_str(result) << ")" + << std::endl; } else { std::cout << "Commanded RTL." << std::endl; } @@ -187,10 +188,10 @@ int main(int argc, char **argv) return 0; } -inline void handle_action_err_exit(ActionResult result, const std::string &message) +inline void handle_action_err_exit(Action::Result result, const std::string &message) { - if (result != ActionResult::SUCCESS) { - std::cerr << ERROR_CONSOLE_TEXT << message << action_result_str(result) + if (result != Action::Result::SUCCESS) { + std::cerr << ERROR_CONSOLE_TEXT << message << Action::result_str(result) << NORMAL_CONSOLE_TEXT << std::endl; exit(EXIT_FAILURE); } diff --git a/example/follow_me/follow_me.cpp b/example/follow_me/follow_me.cpp index 8592d6eee3..4029619657 100644 --- a/example/follow_me/follow_me.cpp +++ b/example/follow_me/follow_me.cpp @@ -31,7 +31,7 @@ using namespace std::this_thread; // for sleep_for() #define TELEMETRY_CONSOLE_TEXT "\033[34m" // Turn text on console blue #define NORMAL_CONSOLE_TEXT "\033[0m" // Restore normal console colour -inline void action_error_exit(ActionResult result, const std::string &message); +inline void action_error_exit(Action::Result result, const std::string &message); inline void follow_me_error_exit(FollowMe::Result result, const std::string &message); inline void connection_error_exit(ConnectionResult result, const std::string &message); @@ -85,7 +85,7 @@ int main(int argc, char **argv) std::cout << "System is ready" << std::endl; // Arm - ActionResult arm_result = action->arm(); + Action::Result arm_result = action->arm(); action_error_exit(arm_result, "Arming failed"); std::cout << "Armed" << std::endl; @@ -100,7 +100,7 @@ int main(int argc, char **argv) std::placeholders::_1)); // Takeoff - ActionResult takeoff_result = action->takeoff(); + Action::Result takeoff_result = action->takeoff(); action_error_exit(takeoff_result, "Takeoff failed"); std::cout << "In Air..." << std::endl; sleep_for(seconds(5)); // Wait for drone to reach takeoff altitude @@ -131,7 +131,7 @@ int main(int argc, char **argv) telemetry->flight_mode_async(nullptr); // Land - const ActionResult land_result = action->land(); + const Action::Result land_result = action->land(); action_error_exit(land_result, "Landing failed"); while (telemetry->in_air()) { std::cout << "waiting until landed" << std::endl; @@ -142,10 +142,10 @@ int main(int argc, char **argv) } // Handles Action's result -inline void action_error_exit(ActionResult result, const std::string &message) +inline void action_error_exit(Action::Result result, const std::string &message) { - if (result != ActionResult::SUCCESS) { - std::cerr << ERROR_CONSOLE_TEXT << message << action_result_str(result) + if (result != Action::Result::SUCCESS) { + std::cerr << ERROR_CONSOLE_TEXT << message << Action::result_str(result) << NORMAL_CONSOLE_TEXT << std::endl; exit(EXIT_FAILURE); } diff --git a/example/offboard_velocity/offboard_velocity.cpp b/example/offboard_velocity/offboard_velocity.cpp index 48ff924d0b..e65f9f7c7f 100644 --- a/example/offboard_velocity/offboard_velocity.cpp +++ b/example/offboard_velocity/offboard_velocity.cpp @@ -26,10 +26,10 @@ using std::chrono::seconds; #define NORMAL_CONSOLE_TEXT "\033[0m" // Restore normal console colour // Handles Action's result -inline void action_error_exit(ActionResult result, const std::string &message) +inline void action_error_exit(Action::Result result, const std::string &message) { - if (result != ActionResult::SUCCESS) { - std::cerr << ERROR_CONSOLE_TEXT << message << action_result_str(result) + if (result != Action::Result::SUCCESS) { + std::cerr << ERROR_CONSOLE_TEXT << message << Action::result_str(result) << NORMAL_CONSOLE_TEXT << std::endl; exit(EXIT_FAILURE); } @@ -213,11 +213,11 @@ int main(int argc, char **argv) } std::cout << "System is ready" << std::endl; - ActionResult arm_result = action->arm(); + Action::Result arm_result = action->arm(); action_error_exit(arm_result, "Arming failed"); std::cout << "Armed" << std::endl; - ActionResult takeoff_result = action->takeoff(); + Action::Result takeoff_result = action->takeoff(); action_error_exit(takeoff_result, "Takeoff failed"); std::cout << "In Air..." << std::endl; sleep_for(seconds(5)); @@ -234,7 +234,7 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - const ActionResult land_result = action->land(); + const Action::Result land_result = action->land(); action_error_exit(land_result, "Landing failed"); // We are relying on auto-disarming but let's keep watching the telemetry for a bit longer. diff --git a/example/takeoff_land/takeoff_and_land.cpp b/example/takeoff_land/takeoff_and_land.cpp index a05547115e..3f68a81684 100644 --- a/example/takeoff_land/takeoff_and_land.cpp +++ b/example/takeoff_land/takeoff_and_land.cpp @@ -100,19 +100,19 @@ int main(int argc, char **argv) // Arm vehicle std::cout << "Arming..." << std::endl; - const ActionResult arm_result = action->arm(); + const Action::Result arm_result = action->arm(); - if (arm_result != ActionResult::SUCCESS) { - std::cout << ERROR_CONSOLE_TEXT << "Arming failed:" << action_result_str(arm_result) + if (arm_result != Action::Result::SUCCESS) { + std::cout << ERROR_CONSOLE_TEXT << "Arming failed:" << Action::result_str(arm_result) << NORMAL_CONSOLE_TEXT << std::endl; return 1; } // Take off std::cout << "Taking off..." << std::endl; - const ActionResult takeoff_result = action->takeoff(); - if (takeoff_result != ActionResult::SUCCESS) { - std::cout << ERROR_CONSOLE_TEXT << "Takeoff failed:" << action_result_str(takeoff_result) + const Action::Result takeoff_result = action->takeoff(); + if (takeoff_result != Action::Result::SUCCESS) { + std::cout << ERROR_CONSOLE_TEXT << "Takeoff failed:" << Action::result_str(takeoff_result) << NORMAL_CONSOLE_TEXT << std::endl; return 1; } @@ -121,9 +121,9 @@ int main(int argc, char **argv) sleep_for(seconds(10)); std::cout << "Landing..." << std::endl; - const ActionResult land_result = action->land(); - if (land_result != ActionResult::SUCCESS) { - std::cout << ERROR_CONSOLE_TEXT << "Land failed:" << action_result_str(land_result) + const Action::Result land_result = action->land(); + if (land_result != Action::Result::SUCCESS) { + std::cout << ERROR_CONSOLE_TEXT << "Land failed:" << Action::result_str(land_result) << NORMAL_CONSOLE_TEXT << std::endl; return 1; } diff --git a/example/transition_vtol_fixed_wing/transition_vtol_fixed_wing.cpp b/example/transition_vtol_fixed_wing/transition_vtol_fixed_wing.cpp index bf89918f88..f11bb97e4f 100644 --- a/example/transition_vtol_fixed_wing/transition_vtol_fixed_wing.cpp +++ b/example/transition_vtol_fixed_wing/transition_vtol_fixed_wing.cpp @@ -97,19 +97,19 @@ int main(int argc, char **argv) // Arm vehicle std::cout << "Arming..." << std::endl; - const ActionResult arm_result = action->arm(); + const Action::Result arm_result = action->arm(); - if (arm_result != ActionResult::SUCCESS) { - std::cout << ERROR_CONSOLE_TEXT << "Arming failed:" << action_result_str(arm_result) + if (arm_result != Action::Result::SUCCESS) { + std::cout << ERROR_CONSOLE_TEXT << "Arming failed:" << Action::result_str(arm_result) << NORMAL_CONSOLE_TEXT << std::endl; return 1; } // Take off std::cout << "Taking off..." << std::endl; - const ActionResult takeoff_result = action->takeoff(); - if (takeoff_result != ActionResult::SUCCESS) { - std::cout << ERROR_CONSOLE_TEXT << "Takeoff failed:" << action_result_str(takeoff_result) + const Action::Result takeoff_result = action->takeoff(); + if (takeoff_result != Action::Result::SUCCESS) { + std::cout << ERROR_CONSOLE_TEXT << "Takeoff failed:" << Action::result_str(takeoff_result) << NORMAL_CONSOLE_TEXT << std::endl; return 1; } @@ -118,11 +118,11 @@ int main(int argc, char **argv) std::this_thread::sleep_for(std::chrono::seconds(10)); std::cout << "Transition to fixedwing..." << std::endl; - const ActionResult fw_result = action->transition_to_fixedwing(); + const Action::Result fw_result = action->transition_to_fixedwing(); - if (fw_result != ActionResult::SUCCESS) { + if (fw_result != Action::Result::SUCCESS) { std::cout << ERROR_CONSOLE_TEXT - << "Transition to fixed wing failed: " << action_result_str(fw_result) + << "Transition to fixed wing failed: " << Action::result_str(fw_result) << NORMAL_CONSOLE_TEXT << std::endl; // return 1; } @@ -131,10 +131,10 @@ int main(int argc, char **argv) std::this_thread::sleep_for(std::chrono::seconds(10)); std::cout << "Transition back to multicopter..." << std::endl; - const ActionResult mc_result = action->transition_to_multicopter(); - if (mc_result != ActionResult::SUCCESS) { + const Action::Result mc_result = action->transition_to_multicopter(); + if (mc_result != Action::Result::SUCCESS) { std::cout << ERROR_CONSOLE_TEXT - << "Transition to multi copter failed:" << action_result_str(mc_result) + << "Transition to multi copter failed:" << Action::result_str(mc_result) << NORMAL_CONSOLE_TEXT << std::endl; // return 1; } @@ -144,10 +144,10 @@ int main(int argc, char **argv) // Return to launch std::cout << "Return to launch..." << std::endl; - const ActionResult rtl_result = action->return_to_launch(); - if (rtl_result != ActionResult::SUCCESS) { + const Action::Result rtl_result = action->return_to_launch(); + if (rtl_result != Action::Result::SUCCESS) { std::cout << ERROR_CONSOLE_TEXT - << "Returning to launch failed:" << action_result_str(rtl_result) + << "Returning to launch failed:" << Action::result_str(rtl_result) << NORMAL_CONSOLE_TEXT << std::endl; // return 1; } @@ -157,9 +157,9 @@ int main(int argc, char **argv) // Land std::cout << "Landing..." << std::endl; - const ActionResult land_result = action->land(); - if (land_result != ActionResult::SUCCESS) { - std::cout << ERROR_CONSOLE_TEXT << "Land failed:" << action_result_str(land_result) + const Action::Result land_result = action->land(); + if (land_result != Action::Result::SUCCESS) { + std::cout << ERROR_CONSOLE_TEXT << "Land failed:" << Action::result_str(land_result) << NORMAL_CONSOLE_TEXT << std::endl; // return 1; }