mavsdk tests: use tester sleep_for function

the previously used std::this_thread::sleep_for is with respect to host
system time which is different from autopilot time if:

 - speed factor != 1
 - something runs slower than realtime regardless of speed factor
 - debugging or otherwise interrupting PX4 control code

tester.sleep_for (which already existed) correctly sleeps w.r.t.
px4/simulation time.
This commit is contained in:
Balduin
2025-03-18 10:25:38 +01:00
committed by Matthias Grob
parent d72c2cc378
commit c0100ed4e7
4 changed files with 36 additions and 42 deletions
@@ -56,12 +56,12 @@ TEST_CASE("Fly VTOL Loiter with airspeed failure", "[vtol_airspeed_fail]")
// tester.wait_until_altitude(50.f, std::chrono::seconds(30));
std::this_thread::sleep_for(std::chrono::seconds(10));
tester.sleep_for(std::chrono::seconds(10));
tester.inject_failure(mavsdk::Failure::FailureUnit::SensorAirspeed, mavsdk::Failure::FailureType::Wrong, 0,
mavsdk::Failure::Result::Success);
std::this_thread::sleep_for(std::chrono::seconds(10));
tester.sleep_for(std::chrono::seconds(10));
tester.check_airspeed_is_invalid(); // it's enough to check once after landing, as invalidation is permanent
}