Skip to content

Commit 8b1307e

Browse files
committed
autotest: add test for simulated Copter clamp
1 parent b00ba16 commit 8b1307e

File tree

2 files changed

+96
-13
lines changed

2 files changed

+96
-13
lines changed

Tools/autotest/arducopter.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10676,6 +10676,78 @@ def MAV_CMD_NAV_TAKEOFF_command_int(self):
1067610676

1067710677
self.reboot_sitl() # unlock home position
1067810678

10679+
def Clamp(self):
10680+
'''test Copter docking clamp'''
10681+
clamp_ch = 11
10682+
self.set_parameters({
10683+
"SIM_CLAMP_CH": clamp_ch,
10684+
})
10685+
10686+
self.takeoff(1, mode='LOITER')
10687+
10688+
self.context_push()
10689+
self.context_collect('STATUSTEXT')
10690+
self.progress("Ensure can't take off with clamp in place")
10691+
self.run_cmd(mavutil.mavlink.MAV_CMD_DO_SET_SERVO, p1=11, p2=2000)
10692+
self.wait_statustext("SITL: Clamp: grabbed vehicle", check_context=True)
10693+
self.arm_vehicle()
10694+
self.set_rc(3, 2000)
10695+
self.wait_altitude(0, 5, minimum_duration=5, relative=True)
10696+
self.run_cmd(mavutil.mavlink.MAV_CMD_DO_SET_SERVO, p1=11, p2=1000)
10697+
self.wait_statustext("SITL: Clamp: released vehicle", check_context=True)
10698+
self.wait_altitude(5, 5000, minimum_duration=1, relative=True)
10699+
self.do_RTL()
10700+
self.set_rc(3, 1000)
10701+
self.change_mode('LOITER')
10702+
self.context_pop()
10703+
10704+
self.progress("Same again for repeatability")
10705+
self.context_push()
10706+
self.context_collect('STATUSTEXT')
10707+
self.run_cmd(mavutil.mavlink.MAV_CMD_DO_SET_SERVO, p1=11, p2=2000)
10708+
self.wait_statustext("SITL: Clamp: grabbed vehicle", check_context=True)
10709+
self.arm_vehicle()
10710+
self.set_rc(3, 2000)
10711+
self.wait_altitude(0, 1, minimum_duration=5, relative=True)
10712+
self.run_cmd(mavutil.mavlink.MAV_CMD_DO_SET_SERVO, p1=11, p2=1000)
10713+
self.wait_statustext("SITL: Clamp: released vehicle", check_context=True)
10714+
self.wait_altitude(5, 5000, minimum_duration=1, relative=True)
10715+
self.do_RTL()
10716+
self.set_rc(3, 1000)
10717+
self.change_mode('LOITER')
10718+
self.context_pop()
10719+
10720+
here = self.mav.location()
10721+
loc = self.offset_location_ne(here, 10, 0)
10722+
self.takeoff(5, mode='GUIDED')
10723+
self.do_reposition(loc, frame=mavutil.mavlink.MAV_FRAME_GLOBAL)
10724+
self.wait_location(loc, timeout=120)
10725+
self.land_and_disarm()
10726+
10727+
# explicitly set home so we RTL to the right spot
10728+
self.set_home(here)
10729+
10730+
self.context_push()
10731+
self.context_collect('STATUSTEXT')
10732+
self.run_cmd(mavutil.mavlink.MAV_CMD_DO_SET_SERVO, p1=11, p2=2000)
10733+
self.wait_statustext("SITL: Clamp: missed vehicle", check_context=True)
10734+
self.run_cmd(mavutil.mavlink.MAV_CMD_DO_SET_SERVO, p1=11, p2=1000)
10735+
self.context_pop()
10736+
10737+
self.takeoff(5, mode='GUIDED')
10738+
self.do_RTL()
10739+
10740+
self.takeoff(5, mode='GUIDED')
10741+
self.land_and_disarm()
10742+
10743+
self.context_push()
10744+
self.context_collect('STATUSTEXT')
10745+
self.run_cmd(mavutil.mavlink.MAV_CMD_DO_SET_SERVO, p1=11, p2=2000)
10746+
self.wait_statustext("SITL: Clamp: grabbed vehicle", check_context=True)
10747+
self.context_pop()
10748+
10749+
self.reboot_sitl() # because we set home
10750+
1067910751
def tests2b(self): # this block currently around 9.5mins here
1068010752
'''return list of all tests'''
1068110753
ret = ([
@@ -10749,6 +10821,7 @@ def tests2b(self): # this block currently around 9.5mins here
1074910821
self.MAV_CMD_SET_EKF_SOURCE_SET,
1075010822
self.MAV_CMD_NAV_TAKEOFF,
1075110823
self.MAV_CMD_NAV_TAKEOFF_command_int,
10824+
self.Clamp,
1075210825
])
1075310826
return ret
1075410827

Tools/autotest/vehicle_test_suite.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6035,19 +6035,20 @@ def run_cmd_int(self,
60356035
command_name = mavutil.mavlink.enums["MAV_CMD"][command].name
60366036
except KeyError:
60376037
command_name = "UNKNOWNu"
6038-
self.progress("Sending COMMAND_INT to (%u,%u) (%s=%u) (p1=%f p2=%f p3=%f p4=%f p5=%u p6=%u p7=%f)" %
6039-
(
6040-
target_sysid,
6041-
target_compid,
6042-
command_name,
6043-
command,
6044-
p1,
6045-
p2,
6046-
p3,
6047-
p4,
6048-
x,
6049-
y,
6050-
z))
6038+
self.progress("Sending COMMAND_INT to (%u,%u) (%s=%u) (p1=%f p2=%f p3=%f p4=%f p5=%u p6=%u p7=%f f=%u)" % (
6039+
target_sysid,
6040+
target_compid,
6041+
command_name,
6042+
command,
6043+
p1,
6044+
p2,
6045+
p3,
6046+
p4,
6047+
x,
6048+
y,
6049+
z,
6050+
frame
6051+
))
60516052
mav.mav.command_int_send(target_sysid,
60526053
target_compid,
60536054
frame,
@@ -8367,6 +8368,7 @@ def run_one_test_attempt(self, test, interact=False, attempt=1, suppress_stdout=
83678368
self.reset_SITL_commandline()
83688369
else:
83698370
self.progress("Force-rebooting SITL")
8371+
self.zero_throttle()
83708372
self.reboot_sitl() # that'll learn it
83718373
passed = False
83728374
elif ardupilot_alive and not passed: # implicit reboot after a failed test:
@@ -10683,6 +10685,14 @@ def GripperType(self, gripper_type):
1068310685
self.context_pop()
1068410686
self.reboot_sitl()
1068510687

10688+
def set_home(self, loc):
10689+
self.run_cmd(
10690+
mavutil.mavlink.MAV_CMD_DO_SET_HOME,
10691+
p5=loc.lat,
10692+
p6=loc.lng,
10693+
p7=loc.alt,
10694+
)
10695+
1068610696
def TestLocalHomePosition(self):
1068710697
"""Test local home position is sent in HOME_POSITION message"""
1068810698
self.context_push()

0 commit comments

Comments
 (0)