From 1c49373088d7cd0c5e3e1bb9cb0f9942b0818161 Mon Sep 17 00:00:00 2001 From: rishabsingh3003 Date: Mon, 9 Jan 2023 23:42:12 +0530 Subject: [PATCH] Tools: Add autotest for checking terrain db pre arm for copter auto mission --- .../TerrainDBPreArm/terrain_wp.txt | 5 +++ Tools/autotest/arducopter.py | 34 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 Tools/autotest/ArduCopter_Tests/TerrainDBPreArm/terrain_wp.txt diff --git a/Tools/autotest/ArduCopter_Tests/TerrainDBPreArm/terrain_wp.txt b/Tools/autotest/ArduCopter_Tests/TerrainDBPreArm/terrain_wp.txt new file mode 100644 index 0000000000..73d2fa98b3 --- /dev/null +++ b/Tools/autotest/ArduCopter_Tests/TerrainDBPreArm/terrain_wp.txt @@ -0,0 +1,5 @@ +QGC WPL 110 +0 1 0 16 0 0 0 0 -35.3633515 149.1652412 585.050000 1 +1 0 10 16 0.00000000 0.00000000 0.00000000 0.00000000 -35.36280600 149.15848020 100.000000 1 +2 0 10 16 0.00000000 0.00000000 0.00000000 0.00000000 -35.36007620 149.16950940 100.000000 1 +3 0 10 16 0.00000000 0.00000000 0.00000000 0.00000000 -35.36653320 149.16929480 100.000000 1 diff --git a/Tools/autotest/arducopter.py b/Tools/autotest/arducopter.py index 162b1971a2..49d0c45e6c 100644 --- a/Tools/autotest/arducopter.py +++ b/Tools/autotest/arducopter.py @@ -2463,6 +2463,37 @@ class AutoTestCopter(AutoTest): self.reboot_sitl() + def TerrainDBPreArm(self): + '''test that pre-arm checks are working corrctly for terrain database''' + self.context_push() + + self.progress("# Load msission with terrain alt") + # load the waypoint + num_wp = self.load_mission("terrain_wp.txt", strict=False) + if not num_wp: + raise NotAchievedException("load terrain_wp failed") + + self.set_analog_rangefinder_parameters() + self.set_parameters({ + "WPNAV_RFND_USE": 1, + "TERRAIN_ENABLE": 1, + }) + self.reboot_sitl() + self.wait_ready_to_arm() + + # make sure we can still arm with valid rangefinder and terrain db disabled + self.set_parameter("TERRAIN_ENABLE", 0) + self.wait_ready_to_arm() + self.progress("# Vehicle armed with terrain db disabled") + + # make sure we can't arm with terrain db enabled and no rangefinder in us + self.set_parameter("WPNAV_RFND_USE", 0) + self.assert_prearm_failure("terrain disabled") + + self.context_pop() + + self.reboot_sitl() + def CopterMission(self): '''fly mission which tests a significant number of commands''' # Fly mission #1 @@ -9525,7 +9556,8 @@ class AutoTestCopter(AutoTest): self.WatchAlts, self.GuidedEKFLaneChange, self.Sprayer, - self.EK3_RNG_USE_HGT + self.EK3_RNG_USE_HGT, + self.TerrainDBPreArm ]) return ret