Skip to content

Commit 03ea95f

Browse files
committed
autotest: update plane switch fence test
the FENCE_AUTOENABLE option should be honoured even with a fence switch in the disable position
1 parent b559536 commit 03ea95f

File tree

1 file changed

+50
-9
lines changed

1 file changed

+50
-9
lines changed

Tools/autotest/arduplane.py

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3661,7 +3661,7 @@ def FenceMinAltAutoEnableAbort(self):
36613661
def FenceAutoEnableDisableSwitch(self):
36623662
'''Tests autoenablement of regular fences and manual disablement'''
36633663
self.set_parameters({
3664-
"FENCE_TYPE": 11, # Set fence type to min alt
3664+
"FENCE_TYPE": 9, # Set fence type to min alt, max alt
36653665
"FENCE_ACTION": 1, # Set action to RTL
36663666
"FENCE_ALT_MIN": 50,
36673667
"FENCE_ALT_MAX": 100,
@@ -3672,35 +3672,60 @@ def FenceAutoEnableDisableSwitch(self):
36723672
"FENCE_RET_ALT" : 0,
36733673
"FENCE_RET_RALLY" : 0,
36743674
"FENCE_TOTAL" : 0,
3675+
"RTL_ALTITUDE" : 75,
36753676
"TKOFF_ALT" : 75,
36763677
"RC7_OPTION" : 11, # AC_Fence uses Aux switch functionality
36773678
})
3679+
self.reboot_sitl()
3680+
self.context_collect("STATUSTEXT")
3681+
36783682
fence_bit = mavutil.mavlink.MAV_SYS_STATUS_GEOFENCE
36793683
# Grab Home Position
36803684
self.mav.recv_match(type='HOME_POSITION', blocking=True)
3681-
self.set_rc_from_map({7: 1000}) # Turn fence off with aux function
3685+
self.set_rc(7, 1000) # Turn fence off with aux function, does not impact later auto-enable
36823686

36833687
self.wait_ready_to_arm()
3688+
3689+
self.progress("Check fence disabled at boot")
3690+
m = self.mav.recv_match(type='SYS_STATUS', blocking=True)
3691+
if (m.onboard_control_sensors_enabled & fence_bit):
3692+
raise NotAchievedException("Fence is enabled at boot")
3693+
36843694
cruise_alt = 75
36853695
self.takeoff(cruise_alt, mode='TAKEOFF')
36863696

3687-
self.progress("Fly above ceiling and check there is no breach")
3697+
self.progress("Fly above ceiling and check there is a breach")
3698+
self.change_mode('FBWA')
36883699
self.set_rc(3, 2000)
3689-
self.change_altitude(cruise_alt + 80, relative=True)
3700+
self.set_rc(2, 1000)
3701+
3702+
self.wait_statustext("Max Alt fence breached", timeout=10, check_context=True)
3703+
self.wait_mode('RTL')
3704+
36903705
m = self.mav.recv_match(type='SYS_STATUS', blocking=True)
3691-
self.progress("Got (%s)" % str(m))
3692-
if (not (m.onboard_control_sensors_health & fence_bit)):
3693-
raise NotAchievedException("Fence Ceiling breached")
3706+
if (m.onboard_control_sensors_health & fence_bit):
3707+
raise NotAchievedException("Fence ceiling not breached")
3708+
3709+
self.set_rc(3, 1500)
3710+
self.set_rc(2, 1500)
3711+
3712+
self.progress("Wait for RTL alt reached")
3713+
self.wait_altitude(cruise_alt-5, cruise_alt+5, relative=True, timeout=30)
36943714

36953715
self.progress("Return to cruise alt")
36963716
self.set_rc(3, 1500)
36973717
self.change_altitude(cruise_alt, relative=True)
36983718

3719+
self.progress("Check fence breach cleared")
3720+
m = self.mav.recv_match(type='SYS_STATUS', blocking=True)
3721+
if (not (m.onboard_control_sensors_health & fence_bit)):
3722+
raise NotAchievedException("Fence breach not cleared")
3723+
36993724
self.progress("Fly below floor and check for breach")
37003725
self.set_rc(2, 2000)
3726+
self.wait_statustext("Min Alt fence breached", timeout=10, check_context=True)
37013727
self.wait_mode("RTL")
37023728
m = self.mav.recv_match(type='SYS_STATUS', blocking=True)
3703-
self.progress("Got (%s)" % str(m))
37043729
if (m.onboard_control_sensors_health & fence_bit):
37053730
raise NotAchievedException("Fence floor not breached")
37063731

@@ -3710,10 +3735,26 @@ def FenceAutoEnableDisableSwitch(self):
37103735
self.set_rc(3, 2000)
37113736
self.change_altitude(75, relative=True)
37123737
m = self.mav.recv_match(type='SYS_STATUS', blocking=True)
3713-
self.progress("Got (%s)" % str(m))
37143738
if (not (m.onboard_control_sensors_enabled & fence_bit)):
37153739
raise NotAchievedException("Fence Floor not enabled")
37163740

3741+
self.progress("Toggle fence enable/disable")
3742+
self.set_rc(7, 2000)
3743+
self.delay_sim_time(2)
3744+
self.set_rc(7, 1000)
3745+
self.delay_sim_time(2)
3746+
3747+
self.progress("Check fence is disabled")
3748+
m = self.mav.recv_match(type='SYS_STATUS', blocking=True)
3749+
if (m.onboard_control_sensors_enabled & fence_bit):
3750+
raise NotAchievedException("Fence disable with switch failed")
3751+
3752+
self.progress("Fly below floor and check for no breach")
3753+
self.change_altitude(40, relative=True)
3754+
m = self.mav.recv_match(type='SYS_STATUS', blocking=True)
3755+
if (not (m.onboard_control_sensors_health & fence_bit)):
3756+
raise NotAchievedException("Fence floor breached")
3757+
37173758
self.progress("Return to cruise alt")
37183759
self.set_rc(3, 1500)
37193760
self.change_altitude(cruise_alt, relative=True)

0 commit comments

Comments
 (0)