mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 10:26:52 +08:00
mavsdk_tests: fix mission finished state
This is an attempt to use MAVSDK's is_mission_finished APIs instead.
This commit is contained in:
@@ -1 +1 @@
|
|||||||
3.4.0
|
3.6.0
|
||||||
|
|||||||
@@ -324,8 +324,8 @@ void AutopilotTester::execute_mission_and_lose_mag()
|
|||||||
// We except the mission to continue without mag just fine.
|
// We except the mission to continue without mag just fine.
|
||||||
REQUIRE(poll_condition_with_timeout(
|
REQUIRE(poll_condition_with_timeout(
|
||||||
[this]() {
|
[this]() {
|
||||||
auto progress = _mission->mission_progress();
|
auto result = _mission->is_mission_finished();
|
||||||
return progress.current == progress.total;
|
return result.first == Mission::Result::Success && result.second;
|
||||||
}, std::chrono::seconds(90)));
|
}, std::chrono::seconds(90)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,8 +340,8 @@ void AutopilotTester::execute_mission_and_lose_baro()
|
|||||||
// We except the mission to continue without baro just fine.
|
// We except the mission to continue without baro just fine.
|
||||||
REQUIRE(poll_condition_with_timeout(
|
REQUIRE(poll_condition_with_timeout(
|
||||||
[this]() {
|
[this]() {
|
||||||
auto progress = _mission->mission_progress();
|
auto result = _mission->is_mission_finished();
|
||||||
return progress.current == progress.total;
|
return result.first == Mission::Result::Success && result.second;
|
||||||
}, std::chrono::seconds(90)));
|
}, std::chrono::seconds(90)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,8 +356,8 @@ void AutopilotTester::execute_mission_and_get_baro_stuck()
|
|||||||
// We except the mission to continue with a stuck baro just fine.
|
// We except the mission to continue with a stuck baro just fine.
|
||||||
REQUIRE(poll_condition_with_timeout(
|
REQUIRE(poll_condition_with_timeout(
|
||||||
[this]() {
|
[this]() {
|
||||||
auto progress = _mission->mission_progress();
|
auto result = _mission->is_mission_finished();
|
||||||
return progress.current == progress.total;
|
return result.first == Mission::Result::Success && result.second;
|
||||||
}, std::chrono::seconds(90)));
|
}, std::chrono::seconds(90)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,8 +372,8 @@ void AutopilotTester::execute_mission_and_get_mag_stuck()
|
|||||||
// We except the mission to continue with a stuck mag just fine.
|
// We except the mission to continue with a stuck mag just fine.
|
||||||
REQUIRE(poll_condition_with_timeout(
|
REQUIRE(poll_condition_with_timeout(
|
||||||
[this]() {
|
[this]() {
|
||||||
auto progress = _mission->mission_progress();
|
auto result = _mission->is_mission_finished();
|
||||||
return progress.current == progress.total;
|
return result.first == Mission::Result::Success && result.second;
|
||||||
}, std::chrono::seconds(120)));
|
}, std::chrono::seconds(120)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -974,34 +974,20 @@ void AutopilotTester::wait_until_speed_lower_than(float speed, std::chrono::seco
|
|||||||
|
|
||||||
void AutopilotTester::wait_for_mission_finished(std::chrono::seconds timeout)
|
void AutopilotTester::wait_for_mission_finished(std::chrono::seconds timeout)
|
||||||
{
|
{
|
||||||
auto prom = std::promise<void> {};
|
REQUIRE(poll_condition_with_timeout(
|
||||||
auto fut = prom.get_future();
|
[ = ]() {
|
||||||
|
auto result = _mission->is_mission_finished();
|
||||||
Mission::MissionProgressHandle handle = _mission->subscribe_mission_progress(
|
return result.first == Mission::Result::Success && result.second;
|
||||||
[&prom, &handle, this](Mission::MissionProgress progress) {
|
}, timeout));
|
||||||
if (progress.current == progress.total) {
|
|
||||||
_mission->unsubscribe_mission_progress(handle);
|
|
||||||
prom.set_value();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
REQUIRE(fut.wait_for(timeout) == std::future_status::ready);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutopilotTester::wait_for_mission_raw_finished(std::chrono::seconds timeout)
|
void AutopilotTester::wait_for_mission_raw_finished(std::chrono::seconds timeout)
|
||||||
{
|
{
|
||||||
auto prom = std::promise<void> {};
|
REQUIRE(poll_condition_with_timeout(
|
||||||
auto fut = prom.get_future();
|
[ = ]() {
|
||||||
|
auto result = _mission_raw->is_mission_finished();
|
||||||
MissionRaw::MissionProgressHandle handle = _mission_raw->subscribe_mission_progress(
|
return result.first == MissionRaw::Result::Success && result.second;
|
||||||
[&prom, &handle, this](MissionRaw::MissionProgress progress) {
|
}, timeout));
|
||||||
if (progress.current == progress.total) {
|
|
||||||
_mission_raw->unsubscribe_mission_progress(handle);
|
|
||||||
prom.set_value();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
REQUIRE(fut.wait_for(timeout) == std::future_status::ready);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutopilotTester::move_mission_raw_here(std::vector<MissionRaw::MissionItem> &mission_items)
|
void AutopilotTester::move_mission_raw_here(std::vector<MissionRaw::MissionItem> &mission_items)
|
||||||
|
|||||||
Reference in New Issue
Block a user