Skip to content

Commit

Permalink
autotest: clean-up fence manipulation functions and add test for auto…
Browse files Browse the repository at this point in the history
…-enablement on copter
  • Loading branch information
andyp1per committed Jan 13, 2024
1 parent d507d47 commit e7aa7c4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
13 changes: 7 additions & 6 deletions Tools/autotest/arducopter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1687,15 +1687,14 @@ def FenceFloorEnabledLanding(self):
self.assert_fence_disabled()

def FenceFloorAutoDisableLanding(self):
"""Ensures we can initiate and complete an RTL while the fence is
enabled.
"""
"""Ensures we can initiate and complete an RTL while the fence is enabled"""

fence_bit = mavutil.mavlink.MAV_SYS_STATUS_GEOFENCE

self.progress("Test Landing while fence floor enabled")
self.set_parameters({
"AVOID_ENABLE": 0,
"FENCE_TYPE": 15,
"FENCE_TYPE": 11,
"FENCE_ALT_MIN": 10,
"FENCE_ALT_MAX": 20,
"FENCE_AUTOENABLE" : 1,
Expand All @@ -1707,7 +1706,7 @@ def FenceFloorAutoDisableLanding(self):
self.user_takeoff(alt_min=15)

# Check fence is enabled
self.do_fence_enable()
self.do_fence_enable_except_floor()
self.assert_fence_enabled()

# Change to RC controlled mode
Expand All @@ -1719,7 +1718,9 @@ def FenceFloorAutoDisableLanding(self):
# Assert fence is not healthy now that we are in RTL
self.assert_sensor_state(fence_bit, healthy=False)

self.wait_landed_and_disarmed()
self.wait_landed_and_disarmed(0)
# the breach should have cleared since we auto-disable the
# fence on landing
self.assert_fence_enabled()

# Assert fence is healthy now that we have landed disarmed
Expand Down
21 changes: 8 additions & 13 deletions Tools/autotest/vehicle_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -6592,22 +6592,17 @@ def do_set_relay_mavproxy(self, relay_num, on_off):
self.mavproxy.expect("Loaded module relay")
self.mavproxy.send("relay set %d %d\n" % (relay_num, on_off))

def do_fence_en_or_dis_able(self, value, want_result=mavutil.mavlink.MAV_RESULT_ACCEPTED):
if value:
p1 = 1
else:
p1 = 0
self.run_cmd(
mavutil.mavlink.MAV_CMD_DO_FENCE_ENABLE,
p1=p1, # param1
want_result=want_result,
)

def do_fence_enable(self, want_result=mavutil.mavlink.MAV_RESULT_ACCEPTED):
self.do_fence_en_or_dis_able(True, want_result=want_result)
self.run_cmd(mavutil.mavlink.MAV_CMD_DO_FENCE_ENABLE, p1=1, want_result=want_result)

def do_fence_disable(self, want_result=mavutil.mavlink.MAV_RESULT_ACCEPTED):
self.do_fence_en_or_dis_able(False, want_result=want_result)
self.run_cmd(mavutil.mavlink.MAV_CMD_DO_FENCE_ENABLE, p1=0, want_result=want_result)

def do_fence_disable_floor(self, want_result=mavutil.mavlink.MAV_RESULT_ACCEPTED):
self.run_cmd(mavutil.mavlink.MAV_CMD_DO_FENCE_ENABLE, p1=0, p2=8, want_result=want_result)

def do_fence_enable_except_floor(self, want_result=mavutil.mavlink.MAV_RESULT_ACCEPTED):
self.run_cmd(mavutil.mavlink.MAV_CMD_DO_FENCE_ENABLE, p1=1, p2=7, want_result=want_result)

#################################################
# WAIT UTILITIES
Expand Down

0 comments on commit e7aa7c4

Please sign in to comment.