mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
autopilot_tester: don't poll mission progress
Instead use subscription here as well in order not to miss an update.
This commit is contained in:
@@ -226,13 +226,7 @@ void AutopilotTester::execute_mission()
|
|||||||
|
|
||||||
// TODO: Adapt time limit based on mission size, flight speed, sim speed factor, etc.
|
// TODO: Adapt time limit based on mission size, flight speed, sim speed factor, etc.
|
||||||
|
|
||||||
REQUIRE(poll_condition_with_timeout(
|
wait_for_mission_finished(std::chrono::seconds(60));
|
||||||
[this]() {
|
|
||||||
auto result = _mission->is_mission_finished();
|
|
||||||
return result.first == Mission::Result::Success && result.second;
|
|
||||||
}, std::chrono::seconds(60)));
|
|
||||||
|
|
||||||
REQUIRE(fut.wait_for(std::chrono::seconds(1)) == std::future_status::ready);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutopilotTester::execute_mission_and_lose_gps()
|
void AutopilotTester::execute_mission_and_lose_gps()
|
||||||
@@ -611,6 +605,21 @@ void AutopilotTester::wait_for_landed_state(Telemetry::LandedState landed_state,
|
|||||||
REQUIRE(fut.wait_for(timeout) == std::future_status::ready);
|
REQUIRE(fut.wait_for(timeout) == std::future_status::ready);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AutopilotTester::wait_for_mission_finished(std::chrono::seconds timeout)
|
||||||
|
{
|
||||||
|
auto prom = std::promise<void> {};
|
||||||
|
auto fut = prom.get_future();
|
||||||
|
|
||||||
|
_mission->subscribe_mission_progress([&prom, this](Mission::MissionProgress progress) {
|
||||||
|
if (progress.current == progress.total) {
|
||||||
|
_mission->subscribe_mission_progress(nullptr);
|
||||||
|
prom.set_value();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
REQUIRE(fut.wait_for(timeout) == std::future_status::ready);
|
||||||
|
}
|
||||||
|
|
||||||
std::chrono::milliseconds AutopilotTester::adjust_to_lockstep_speed(std::chrono::milliseconds duration_ms)
|
std::chrono::milliseconds AutopilotTester::adjust_to_lockstep_speed(std::chrono::milliseconds duration_ms)
|
||||||
{
|
{
|
||||||
if (_info == nullptr) {
|
if (_info == nullptr) {
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ private:
|
|||||||
void start_and_wait_for_first_mission_item();
|
void start_and_wait_for_first_mission_item();
|
||||||
void wait_for_flight_mode(Telemetry::FlightMode flight_mode, std::chrono::seconds timeout);
|
void wait_for_flight_mode(Telemetry::FlightMode flight_mode, std::chrono::seconds timeout);
|
||||||
void wait_for_landed_state(Telemetry::LandedState landed_state, std::chrono::seconds timeout);
|
void wait_for_landed_state(Telemetry::LandedState landed_state, std::chrono::seconds timeout);
|
||||||
|
void wait_for_mission_finished(std::chrono::seconds timeout);
|
||||||
|
|
||||||
std::chrono::milliseconds adjust_to_lockstep_speed(std::chrono::milliseconds duration_ms);
|
std::chrono::milliseconds adjust_to_lockstep_speed(std::chrono::milliseconds duration_ms);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user