diff --git a/src/integration_tests/follow_me.cpp b/src/integration_tests/follow_me.cpp index 75d579568c..75c59ea298 100644 --- a/src/integration_tests/follow_me.cpp +++ b/src/integration_tests/follow_me.cpp @@ -11,15 +11,14 @@ #include "plugins/action/action.h" #include "plugins/follow_me/follow_me.h" #include "plugins/info/info.h" +#include "plugins/param/param.h" using namespace mavsdk; using namespace std::chrono; using namespace std::this_thread; -/* Updated FollowMe only works from PX4 v1.13, as it went through refactoring */ -const int32_t PX4_SW_MAJOR_MINIMUM = 1; -const int32_t PX4_SW_MINOR_MINIMUM = 13; -bool autopilot_sw_ver_minimum_satisfied(const std::shared_ptr info); +/* Check if the autopilot supports improved follow me */ +bool autopilot_has_improved_followme(const std::shared_ptr param); /* Auxilary Functions */ void print(const FollowMe::Config& config); @@ -45,9 +44,10 @@ TEST_F(SitlTest, PX4FollowMeOneLocation) auto telemetry = std::make_shared(system); auto follow_me = std::make_shared(system); auto action = std::make_shared(system); - auto info = std::make_shared(system); + auto param = std::make_shared(system); - if (!autopilot_sw_ver_minimum_satisfied(info)) { + // Skip the test if the Autopilot doesn't support the improved Follow Me (in MAVSDK v2) + if (!autopilot_has_improved_followme(param)) { GTEST_SKIP(); } @@ -138,9 +138,10 @@ TEST_F(SitlTest, PX4FollowMeMultiLocationWithConfig) auto telemetry = std::make_shared(system); auto follow_me = std::make_shared(system); auto action = std::make_shared(system); - auto info = std::make_shared(system); + auto param = std::make_shared(system); - if (!autopilot_sw_ver_minimum_satisfied(info)) { + // Skip the test if the Autopilot doesn't support the improved Follow Me (in MAVSDK v2) + if (!autopilot_has_improved_followme(param)) { GTEST_SKIP(); } @@ -224,27 +225,17 @@ FollowMe::TargetLocation create_target_location(double latitude_deg, double long return location; } -bool autopilot_sw_ver_minimum_satisfied(const std::shared_ptr info) +bool autopilot_has_improved_followme(const std::shared_ptr param) { - EXPECT_TRUE(poll_condition_with_timeout( - [&]() { return info->get_version().first == Info::Result::Success; }, - std::chrono::seconds(5))); - - // Check PX4 version running and if too low, skip the test - std::pair version_result = info->get_version(); - EXPECT_EQ(version_result.first, Info::Result::Success); - - if (version_result.second.flight_sw_major < PX4_SW_MAJOR_MINIMUM) { - return false; // Major version not satisfied - - } else if (version_result.second.flight_sw_major > PX4_SW_MAJOR_MINIMUM) { - return true; // Major version satisfied - - } else if (version_result.second.flight_sw_minor >= PX4_SW_MINOR_MINIMUM) { - return true; // Major version same, minor version satisfied + // Check if the newly added parameter in the improved follow-me exists + // Improved Follow-Me PR: https://github.com/PX4/PX4-Autopilot/pull/18026 + const std::pair get_result = param->get_param_float("FLW_TGT_MAX_VEL"); + + if (get_result.first == Param::Result::Success) { + return true; + } else { + return false; } - - return false; } void send_location_updates(std::shared_ptr follow_me, size_t count, float rate)