mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-01 21:48:28 -04:00
Tools: autotest: add simple test that althold works
This commit is contained in:
parent
ead3682e4c
commit
e800ae21ed
@ -236,6 +236,28 @@ class AutoTestCopter(AutoTest):
|
|||||||
|
|
||||||
self.do_RTL()
|
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):
|
def change_alt(self, alt_min, climb_throttle=1920, descend_throttle=1080):
|
||||||
"""Change altitude."""
|
"""Change altitude."""
|
||||||
m = self.mav.recv_match(type='GLOBAL_POSITION_INT', blocking=True)
|
m = self.mav.recv_match(type='GLOBAL_POSITION_INT', blocking=True)
|
||||||
@ -2869,6 +2891,10 @@ class AutoTestCopter(AutoTest):
|
|||||||
"GPS Glitch Auto Test",
|
"GPS Glitch Auto Test",
|
||||||
self.fly_gps_glitch_auto_test),
|
self.fly_gps_glitch_auto_test),
|
||||||
|
|
||||||
|
("ModeAltHold",
|
||||||
|
"Test AltHold Mode",
|
||||||
|
self.test_mode_ALT_HOLD),
|
||||||
|
|
||||||
("ModeLoiter",
|
("ModeLoiter",
|
||||||
"Test Loiter Mode",
|
"Test Loiter Mode",
|
||||||
self.loiter),
|
self.loiter),
|
||||||
|
Loading…
Reference in New Issue
Block a user