Skip to content

Commit a76eb8e

Browse files
committed
autotest: add test for auto-disabling min alt fence breaches on disarming
1 parent ea8d2cb commit a76eb8e

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

Tools/autotest/arducopter.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,16 +1675,60 @@ def FenceFloorEnabledLanding(self):
16751675
self.set_rc(3, 1800)
16761676

16771677
self.wait_mode('RTL', timeout=120)
1678+
16781679
self.wait_landed_and_disarmed()
16791680
self.assert_fence_enabled()
16801681

1681-
# Assert fence is not healthy
1682+
# Assert fence is healthy now that we have landed disarmed
16821683
self.assert_sensor_state(fence_bit, healthy=False)
16831684

16841685
# Disable the fence using mavlink command to ensure cleaned up SITL state
16851686
self.do_fence_disable()
16861687
self.assert_fence_disabled()
16871688

1689+
def FenceFloorAutoDisableLanding(self):
1690+
"""Ensures we can initiate and complete an RTL while the fence is
1691+
enabled.
1692+
"""
1693+
fence_bit = mavutil.mavlink.MAV_SYS_STATUS_GEOFENCE
1694+
1695+
self.progress("Test Landing while fence floor enabled")
1696+
self.set_parameters({
1697+
"AVOID_ENABLE": 0,
1698+
"FENCE_TYPE": 15,
1699+
"FENCE_ALT_MIN": 10,
1700+
"FENCE_ALT_MAX": 20,
1701+
"FENCE_OPTIONS" : 4,
1702+
})
1703+
1704+
self.change_mode("GUIDED")
1705+
self.wait_ready_to_arm()
1706+
self.arm_vehicle()
1707+
self.user_takeoff(alt_min=15)
1708+
1709+
# Check fence is enabled
1710+
self.do_fence_enable()
1711+
self.assert_fence_enabled()
1712+
1713+
# Change to RC controlled mode
1714+
self.change_mode('LOITER')
1715+
1716+
self.set_rc(3, 1800)
1717+
1718+
self.wait_mode('RTL', timeout=120)
1719+
# Assert fence is not healthy now that we are in RTL
1720+
self.assert_sensor_state(fence_bit, healthy=False)
1721+
1722+
self.wait_landed_and_disarmed()
1723+
self.assert_fence_enabled()
1724+
1725+
# Assert fence is healthy now that we have landed disarmed
1726+
self.assert_sensor_state(fence_bit, healthy=True)
1727+
1728+
# Disable the fence using mavlink command to ensure cleaned up SITL state
1729+
self.do_fence_disable()
1730+
self.assert_fence_disabled()
1731+
16881732
def GPSGlitchLoiter(self, timeout=30, max_distance=20):
16891733
"""fly_gps_glitch_loiter_test. Fly south east in loiter and test
16901734
reaction to gps glitch."""
@@ -10056,6 +10100,7 @@ def tests1d(self):
1005610100
self.MaxAltFence,
1005710101
self.MinAltFence,
1005810102
self.FenceFloorEnabledLanding,
10103+
self.FenceFloorAutoDisableLanding,
1005910104
self.AutoTuneSwitch,
1006010105
self.GPSGlitchLoiter,
1006110106
self.GPSGlitchLoiter2,

0 commit comments

Comments
 (0)