AutoTest: Move fence enable/disable to common location

This commit is contained in:
James O'Shannessy 2021-01-07 11:40:18 +11:00 committed by Peter Barker
parent 528defd560
commit 47e76a1807
3 changed files with 22 additions and 29 deletions

View File

@ -1354,14 +1354,7 @@ class AutoTestCopter(AutoTest):
# Activate the floor fence
# TODO this test should run without requiring this
self.run_cmd(mavutil.mavlink.MAV_CMD_DO_FENCE_ENABLE,
1,
0,
0,
0,
0,
0,
0)
self.do_fence_enable()
# first east
self.progress("turn east")

View File

@ -1038,27 +1038,6 @@ class AutoTestPlane(AutoTest):
raise NotAchievedException("fence status incorrect; %s want=%u got=%u" %
(name, want, got))
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, # param1
0, # param2
0, # param3
0, # param4
0, # param5
0, # param6
0, # param7
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)
def do_fence_disable(self, want_result=mavutil.mavlink.MAV_RESULT_ACCEPTED):
self.do_fence_en_or_dis_able(False, want_result=want_result)
def wait_circling_point_with_radius(self, loc, want_radius, epsilon=5.0, min_circle_time=5, timeout=120):
on_radius_start_heading = None
average_radius = 0.0

View File

@ -4619,6 +4619,27 @@ class AutoTest(ABC):
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, # param1
0, # param2
0, # param3
0, # param4
0, # param5
0, # param6
0, # param7
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)
def do_fence_disable(self, want_result=mavutil.mavlink.MAV_RESULT_ACCEPTED):
self.do_fence_en_or_dis_able(False, want_result=want_result)
#################################################
# WAIT UTILITIES
#################################################