From fecf7c2e0c02b1eb9e9e1b04d585fd6338f8ccf6 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 1 Aug 2022 18:49:40 +1000 Subject: [PATCH] autotest: augment Plane TerrainMission to check we *do* follow the terrain --- Tools/autotest/arduplane.py | 28 ++++++++++++++++++++++++++-- Tools/autotest/common.py | 4 ++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Tools/autotest/arduplane.py b/Tools/autotest/arduplane.py index 3cf0ed5121..07bf77ea94 100644 --- a/Tools/autotest/arduplane.py +++ b/Tools/autotest/arduplane.py @@ -533,6 +533,9 @@ class AutoTestPlane(AutoTest): """Fly a mission from a file.""" self.progress("Flying mission %s" % filename) num_wp = self.load_mission(filename, strict=strict)-1 + self.fly_mission_waypoints(num_wp, mission_timeout=mission_timeout, quadplane=quadplane) + + def fly_mission_waypoints(self, num_wp, mission_timeout=60.0, quadplane=False): self.set_current_waypoint(0, check_afterwards=False) self.context_push() self.context_collect('STATUSTEXT') @@ -2562,10 +2565,31 @@ function''' def TerrainMission(self): - self.wait_ready_to_arm() + mavproxy = self.start_mavproxy() + + num_wp = self.load_mission("ap-terrain.txt") + + self.wait_ready_to_arm(timeout=120*60) # time to get terrain self.arm_vehicle() - self.fly_mission("ap-terrain.txt", mission_timeout=600) + global max_alt + max_alt = 0 + + def record_maxalt(mav, m): + global max_alt + if m.get_type() != 'GLOBAL_POSITION_INT': + return + if m.relative_alt/1000.0 > max_alt: + max_alt = m.relative_alt/1000.0 + + self.install_message_hook(record_maxalt) + + self.fly_mission_waypoints(num_wp-1, mission_timeout=600) + + self.stop_mavproxy(mavproxy) + + if max_alt < 200: + raise NotAchievedException("Did not follow terrain") def Terrain(self): '''test AP_Terrain''' diff --git a/Tools/autotest/common.py b/Tools/autotest/common.py index 10d79165ac..f96c1c9e2a 100644 --- a/Tools/autotest/common.py +++ b/Tools/autotest/common.py @@ -7042,6 +7042,10 @@ Also, ignores heartbeats not from our target system''' def remove_bin_logs(self): util.run_cmd('/bin/rm -f logs/*.BIN logs/LASTLOG.TXT') + def remove_ardupilot_terrain_cache(self): + '''removes the terrain files ArduPilot keeps in its onboiard storage''' + util.run_cmd('/bin/rm -f %s' % util.reltopdir("terrain/*.DAT")) + def check_logs(self, name): '''called to move relevant log files from our working directory to the buildlogs directory'''