mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 02:43:33 +08:00
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:
@@ -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.);
|
||||
|
||||
Reference in New Issue
Block a user