From aa72b7da4674c6927d70f50aebb9cc94a4848fc1 Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Sun, 4 Apr 2021 20:34:45 +0100 Subject: [PATCH] Tools: autotest: Plane: add loiter terrain following test --- .../ArduPlane_Tests/Terrain-loiter/flaps.txt | 13 +++++++ Tools/autotest/arduplane.py | 35 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 Tools/autotest/ArduPlane_Tests/Terrain-loiter/flaps.txt diff --git a/Tools/autotest/ArduPlane_Tests/Terrain-loiter/flaps.txt b/Tools/autotest/ArduPlane_Tests/Terrain-loiter/flaps.txt new file mode 100644 index 0000000000..93d0726c86 --- /dev/null +++ b/Tools/autotest/ArduPlane_Tests/Terrain-loiter/flaps.txt @@ -0,0 +1,13 @@ +QGC WPL 110 +0 0 0 16 0.000000 0.000000 0.000000 0.000000 -35.363262 149.165237 584.390015 1 +1 0 3 22 15.000000 0.000000 0.000000 0.000000 -35.361279 149.164230 30.000000 1 +2 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.361229 149.163025 80.000000 1 +3 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.364563 149.163773 80.000000 1 +4 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.364384 149.164795 80.000000 1 +5 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.361027 149.164093 80.000000 1 +6 0 0 177 2.000000 3.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1 +7 0 3 189 0.000000 0.000000 0.000000 0.000000 -35.362915 149.162613 60.000000 1 +8 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.363136 149.162750 60.000000 1 +9 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.365467 149.164215 55.000000 1 +10 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.365009 149.165482 39.889999 1 +11 0 3 21 0.000000 0.000000 0.000000 1.000000 -35.363041 149.165222 0.000000 1 diff --git a/Tools/autotest/arduplane.py b/Tools/autotest/arduplane.py index 9d96716de1..37c4445149 100644 --- a/Tools/autotest/arduplane.py +++ b/Tools/autotest/arduplane.py @@ -2184,6 +2184,36 @@ class AutoTestPlane(AutoTest): self.fly_mission("ap-terrain.txt", mission_timeout=600) + def test_loiter_terrain(self): + default_rad = self.get_parameter("WP_LOITER_RAD") + self.set_parameter("TERRAIN_FOLLOW", 1) # enable terrain following in loiter + self.set_parameter("WP_LOITER_RAD", 2000) # set very large loiter rad to get some terrain changes + alt = 200 + self.takeoff(alt*0.9, alt*1.1) + self.set_rc(3, 1500) + self.change_mode("LOITER") + self.progress("loitering at %um" % alt) + tstart = self.get_sim_time() + while True: + now = self.get_sim_time_cached() + if now - tstart > 60*15: # enough time to do one and a bit circles + break + terrain = self.mav.recv_match( + type='TERRAIN_REPORT', + blocking=True, + timeout=1 + ) + if terrain is None: + raise NotAchievedException("Did not get TERRAIN_REPORT message") + rel_alt = terrain.current_height + self.progress("%um above terrain" % rel_alt) + if rel_alt > alt*1.2 or rel_alt < alt * 0.8: + raise NotAchievedException("Not terrain following") + self.progress("Returning home") + self.set_parameter("TERRAIN_FOLLOW", 0) + self.set_parameter("WP_LOITER_RAD", default_rad) + self.fly_home_land_and_disarm(240) + def fly_external_AHRS(self): """Fly with external AHRS (VectorNav)""" self.customise_SITL_commandline(["--uartE=sim:VectorNav"]) @@ -2921,6 +2951,10 @@ class AutoTestPlane(AutoTest): "Test terrain following in mission", self.fly_terrain_mission), + ("Terrain-loiter", + "Test terrain following in loiter", + self.test_loiter_terrain), + ("ExternalAHRS", "Test external AHRS support", self.fly_external_AHRS), @@ -2965,4 +2999,5 @@ class AutoTestPlane(AutoTest): def disabled_tests(self): return { + "Terrain-loiter": "Loading of terrain data is not reliable", }