Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only enable follow-me test if the improved followme' parameter exists #1847

Merged
merged 2 commits into from
Jul 8, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 18 additions & 27 deletions src/integration_tests/follow_me.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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> info);
/* Check if the autopilot supports improved follow me */
bool autopilot_has_improved_followme(const std::shared_ptr<Param> param);

/* Auxilary Functions */
void print(const FollowMe::Config& config);
Expand All @@ -45,9 +44,10 @@ TEST_F(SitlTest, PX4FollowMeOneLocation)
auto telemetry = std::make_shared<Telemetry>(system);
auto follow_me = std::make_shared<FollowMe>(system);
auto action = std::make_shared<Action>(system);
auto info = std::make_shared<Info>(system);
auto param = std::make_shared<Param>(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();
}

Expand Down Expand Up @@ -138,9 +138,10 @@ TEST_F(SitlTest, PX4FollowMeMultiLocationWithConfig)
auto telemetry = std::make_shared<Telemetry>(system);
auto follow_me = std::make_shared<FollowMe>(system);
auto action = std::make_shared<Action>(system);
auto info = std::make_shared<Info>(system);
auto param = std::make_shared<Param>(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();
}

Expand Down Expand Up @@ -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> info)
bool autopilot_has_improved_followme(const std::shared_ptr<Param> 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<Info::Result, Info::Version> 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<Param::Result, float> 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<FollowMe> follow_me, size_t count, float rate)
Expand Down