Tools: autotest: add simple test that althold works

This commit is contained in:
Peter Barker 2019-03-06 12:29:32 +11:00 committed by Peter Barker
parent ead3682e4c
commit e800ae21ed
1 changed files with 26 additions and 0 deletions

View File

@ -236,6 +236,28 @@ class AutoTestCopter(AutoTest):
self.do_RTL()
def watch_altitude_maintained(self, min_alt, max_alt, timeout=10):
'''watch alt, relative alt must remain between min_alt and max_alt'''
tstart = self.get_sim_time_cached()
while True:
if self.get_sim_time_cached() - tstart > timeout:
return
m = self.mav.recv_match(type='VFR_HUD', blocking=True)
if m.alt <= min_alt:
raise NotAchievedException("Altitude not maintained: want >%f got=%f" % (min_alt, m.alt))
def test_mode_ALT_HOLD(self):
self.takeoff(10, mode="ALT_HOLD")
self.watch_altitude_maintained(9, 11, timeout=5)
# feed in full elevator and aileron input and make sure we
# retain altitude:
self.set_rc(1, 1000)
self.set_rc(2, 1000)
self.watch_altitude_maintained(9, 11, timeout=5)
self.set_rc(1, 1500)
self.set_rc(2, 1500)
self.do_RTL()
def change_alt(self, alt_min, climb_throttle=1920, descend_throttle=1080):
"""Change altitude."""
m = self.mav.recv_match(type='GLOBAL_POSITION_INT', blocking=True)
@ -2869,6 +2891,10 @@ class AutoTestCopter(AutoTest):
"GPS Glitch Auto Test",
self.fly_gps_glitch_auto_test),
("ModeAltHold",
"Test AltHold Mode",
self.test_mode_ALT_HOLD),
("ModeLoiter",
"Test Loiter Mode",
self.loiter),