autotest: test MAV_CMD_NAV_TAKEOFF on Copter

This commit is contained in:
Peter Barker 2023-10-17 15:23:23 +11:00 committed by Peter Barker
parent 5c546dedcb
commit 7de20c09f2
1 changed files with 41 additions and 0 deletions

View File

@ -10370,6 +10370,46 @@ class AutoTestCopter(AutoTest):
self._MAV_CMD_SET_EKF_SOURCE_SET(self.run_cmd) self._MAV_CMD_SET_EKF_SOURCE_SET(self.run_cmd)
self._MAV_CMD_SET_EKF_SOURCE_SET(self.run_cmd_int) self._MAV_CMD_SET_EKF_SOURCE_SET(self.run_cmd_int)
def MAV_CMD_NAV_TAKEOFF(self):
'''test issuing takeoff command via mavlink'''
self.change_mode('GUIDED')
self.wait_ready_to_arm()
self.arm_vehicle()
self.run_cmd(mavutil.mavlink.MAV_CMD_NAV_TAKEOFF, p7=5)
self.wait_altitude(4.5, 5.5, minimum_duration=5, relative=True)
self.change_mode('LAND')
self.wait_disarmed()
self.start_subtest("Check NAV_TAKEOFF is above home location, not current location")
# reset home 20 metres above current location
current_alt_abs = self.get_altitude(relative=False)
loc = self.mav.location()
home_z_ofs = 20
self.run_cmd(
mavutil.mavlink.MAV_CMD_DO_SET_HOME,
p5=loc.lat,
p6=loc.lng,
p7=current_alt_abs + home_z_ofs,
)
self.change_mode('GUIDED')
self.arm_vehicle()
takeoff_alt = 5
self.run_cmd(mavutil.mavlink.MAV_CMD_NAV_TAKEOFF, p7=takeoff_alt)
self.wait_altitude(
current_alt_abs + home_z_ofs + takeoff_alt - 0.5,
current_alt_abs + home_z_ofs + takeoff_alt + 0.5,
minimum_duration=5,
relative=False,
)
self.change_mode('LAND')
self.wait_disarmed()
self.reboot_sitl() # unlock home position
def tests2b(self): # this block currently around 9.5mins here def tests2b(self): # this block currently around 9.5mins here
'''return list of all tests''' '''return list of all tests'''
ret = ([ ret = ([
@ -10437,6 +10477,7 @@ class AutoTestCopter(AutoTest):
self.MAV_CMD_DO_FLIGHTTERMINATION, self.MAV_CMD_DO_FLIGHTTERMINATION,
self.MAV_CMD_DO_LAND_START, self.MAV_CMD_DO_LAND_START,
self.MAV_CMD_SET_EKF_SOURCE_SET, self.MAV_CMD_SET_EKF_SOURCE_SET,
self.MAV_CMD_NAV_TAKEOFF,
]) ])
return ret return ret