mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-27 18:27:05 +08:00
mavsdk_tests: add tests for GPS as height source
This commit is contained in:
@@ -159,6 +159,18 @@ void AutopilotTester::set_takeoff_altitude(const float altitude_m)
|
|||||||
CHECK(result.second == Approx(altitude_m));
|
CHECK(result.second == Approx(altitude_m));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AutopilotTester::set_height_source(AutopilotTester::HeightSource height_source)
|
||||||
|
{
|
||||||
|
switch (height_source) {
|
||||||
|
case HeightSource::Baro:
|
||||||
|
CHECK(_param->set_param_int("EKF2_HGT_MODE", 0) == Param::Result::Success);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HeightSource::Gps:
|
||||||
|
CHECK(_param->set_param_int("EKF2_HGT_MODE", 1) == Param::Result::Success);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AutopilotTester::arm()
|
void AutopilotTester::arm()
|
||||||
{
|
{
|
||||||
const auto result = _action->arm();
|
const auto result = _action->arm();
|
||||||
|
|||||||
@@ -61,12 +61,18 @@ public:
|
|||||||
bool fly_through {false};
|
bool fly_through {false};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class HeightSource {
|
||||||
|
Baro,
|
||||||
|
Gps
|
||||||
|
};
|
||||||
|
|
||||||
void connect(const std::string uri);
|
void connect(const std::string uri);
|
||||||
void wait_until_ready();
|
void wait_until_ready();
|
||||||
void wait_until_ready_local_position_only();
|
void wait_until_ready_local_position_only();
|
||||||
void store_home();
|
void store_home();
|
||||||
void check_home_within(float acceptance_radius_m);
|
void check_home_within(float acceptance_radius_m);
|
||||||
void set_takeoff_altitude(const float altitude_m);
|
void set_takeoff_altitude(const float altitude_m);
|
||||||
|
void set_height_source(HeightSource height_source);
|
||||||
void arm();
|
void arm();
|
||||||
void takeoff();
|
void takeoff();
|
||||||
void land();
|
void land();
|
||||||
|
|||||||
@@ -39,10 +39,28 @@
|
|||||||
#include "autopilot_tester.h"
|
#include "autopilot_tester.h"
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("Land on GPS lost during mission", "[multicopter][vtol]")
|
TEST_CASE("Land on GPS lost during mission (baro height mode)", "[multicopter][vtol]")
|
||||||
{
|
{
|
||||||
AutopilotTester tester;
|
AutopilotTester tester;
|
||||||
tester.connect(connection_url);
|
tester.connect(connection_url);
|
||||||
|
|
||||||
|
tester.set_height_source(AutopilotTester::HeightSource::Baro);
|
||||||
|
tester.wait_until_ready();
|
||||||
|
|
||||||
|
AutopilotTester::MissionOptions mission_options;
|
||||||
|
mission_options.rtl_at_end = true;
|
||||||
|
tester.prepare_square_mission(mission_options);
|
||||||
|
tester.arm();
|
||||||
|
tester.execute_mission_and_lose_gps();
|
||||||
|
tester.wait_until_disarmed();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Land on GPS lost during mission (GPS height mode)", "[multicopter][vtol]")
|
||||||
|
{
|
||||||
|
AutopilotTester tester;
|
||||||
|
tester.connect(connection_url);
|
||||||
|
|
||||||
|
tester.set_height_source(AutopilotTester::HeightSource::Gps);
|
||||||
tester.wait_until_ready();
|
tester.wait_until_ready();
|
||||||
|
|
||||||
AutopilotTester::MissionOptions mission_options;
|
AutopilotTester::MissionOptions mission_options;
|
||||||
@@ -81,10 +99,11 @@ TEST_CASE("Continue on mag stuck during mission", "[multicopter][vtol]")
|
|||||||
tester.wait_until_disarmed();
|
tester.wait_until_disarmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Continue on baro lost during mission", "[multicopter][vtol]")
|
TEST_CASE("Continue on baro lost during mission (baro height mode)", "[multicopter][vtol]")
|
||||||
{
|
{
|
||||||
AutopilotTester tester;
|
AutopilotTester tester;
|
||||||
tester.connect(connection_url);
|
tester.connect(connection_url);
|
||||||
|
tester.set_height_source(AutopilotTester::HeightSource::Baro);
|
||||||
tester.wait_until_ready();
|
tester.wait_until_ready();
|
||||||
|
|
||||||
AutopilotTester::MissionOptions mission_options;
|
AutopilotTester::MissionOptions mission_options;
|
||||||
@@ -95,10 +114,41 @@ TEST_CASE("Continue on baro lost during mission", "[multicopter][vtol]")
|
|||||||
tester.wait_until_disarmed();
|
tester.wait_until_disarmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Continue on baro stuck during mission", "[multicopter][vtol]")
|
TEST_CASE("Continue on baro lost during mission (GPS height mode)", "[multicopter][vtol]")
|
||||||
{
|
{
|
||||||
AutopilotTester tester;
|
AutopilotTester tester;
|
||||||
tester.connect(connection_url);
|
tester.connect(connection_url);
|
||||||
|
tester.set_height_source(AutopilotTester::HeightSource::Gps);
|
||||||
|
tester.wait_until_ready();
|
||||||
|
|
||||||
|
AutopilotTester::MissionOptions mission_options;
|
||||||
|
mission_options.rtl_at_end = true;
|
||||||
|
tester.prepare_square_mission(mission_options);
|
||||||
|
tester.arm();
|
||||||
|
tester.execute_mission_and_lose_baro();
|
||||||
|
tester.wait_until_disarmed();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Continue on baro stuck during mission (baro height mode)", "[multicopter][vtol]")
|
||||||
|
{
|
||||||
|
AutopilotTester tester;
|
||||||
|
tester.connect(connection_url);
|
||||||
|
tester.set_height_source(AutopilotTester::HeightSource::Baro);
|
||||||
|
tester.wait_until_ready();
|
||||||
|
|
||||||
|
AutopilotTester::MissionOptions mission_options;
|
||||||
|
mission_options.rtl_at_end = true;
|
||||||
|
tester.prepare_square_mission(mission_options);
|
||||||
|
tester.arm();
|
||||||
|
tester.execute_mission_and_get_baro_stuck();
|
||||||
|
tester.wait_until_disarmed();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Continue on baro stuck during mission (GPS height mode)", "[multicopter][vtol]")
|
||||||
|
{
|
||||||
|
AutopilotTester tester;
|
||||||
|
tester.connect(connection_url);
|
||||||
|
tester.set_height_source(AutopilotTester::HeightSource::Gps);
|
||||||
tester.wait_until_ready();
|
tester.wait_until_ready();
|
||||||
|
|
||||||
AutopilotTester::MissionOptions mission_options;
|
AutopilotTester::MissionOptions mission_options;
|
||||||
|
|||||||
Reference in New Issue
Block a user