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
+4 -4
View File
@@ -44,14 +44,14 @@ TEST_CASE("Figure eight execution clockwise", "[vtol]")
tester.store_home();
const float takeoff_altitude = 20.f;
tester.set_takeoff_altitude(takeoff_altitude);
std::this_thread::sleep_for(std::chrono::seconds(3));
tester.sleep_for(std::chrono::seconds(3));
tester.arm();
tester.takeoff();
tester.wait_until_hovering();
tester.wait_until_altitude(takeoff_altitude, std::chrono::seconds(30));
tester.transition_to_fixedwing();
tester.wait_until_fixedwing(std::chrono::seconds(5));
std::this_thread::sleep_for(std::chrono::seconds(1));
tester.sleep_for(std::chrono::seconds(1));
tester.set_figure_eight(150., 50., 0., 200., 0., 20.);
tester.execute_figure_eight();
tester.check_tracks_figure_eight(std::chrono::seconds(120), 10.);
@@ -67,14 +67,14 @@ TEST_CASE("Figure eight execution counterclockwise", "[vtol]")
tester.store_home();
const float takeoff_altitude = 20.f;
tester.set_takeoff_altitude(takeoff_altitude);
std::this_thread::sleep_for(std::chrono::seconds(3));
tester.sleep_for(std::chrono::seconds(3));
tester.arm();
tester.takeoff();
tester.wait_until_hovering();
tester.wait_until_altitude(takeoff_altitude, std::chrono::seconds(30));
tester.transition_to_fixedwing();
tester.wait_until_fixedwing(std::chrono::seconds(5));
std::this_thread::sleep_for(std::chrono::seconds(1));
tester.sleep_for(std::chrono::seconds(1));
tester.set_figure_eight(-150., 50., 30.*M_PI / 180., 200., 0., 20.);
tester.execute_figure_eight();
tester.check_tracks_figure_eight(std::chrono::seconds(120), 10.);