autotest: tweak plane autotest debugging

This commit is contained in:
Andrew Tridgell 2013-10-10 09:53:51 +11:00
parent b3af59cc0c
commit 8f558609a9
2 changed files with 18 additions and 10 deletions

View File

@ -153,6 +153,9 @@ def wait_level_flight(mavproxy, mav, accuracy=5, timeout=30):
'''wait for level flight''' '''wait for level flight'''
tstart = time.time() tstart = time.time()
print("Waiting for level flight") print("Waiting for level flight")
mavproxy.send('rc 1 1500\n')
mavproxy.send('rc 2 1500\n')
mavproxy.send('rc 4 1500\n')
while time.time() < tstart + timeout: while time.time() < tstart + timeout:
m = mav.recv_match(type='ATTITUDE', blocking=True) m = mav.recv_match(type='ATTITUDE', blocking=True)
roll = math.degrees(m.roll) roll = math.degrees(m.roll)
@ -196,10 +199,13 @@ def axial_left_roll(mavproxy, mav, count=1):
print("Starting roll") print("Starting roll")
mavproxy.send('rc 1 1000\n') mavproxy.send('rc 1 1000\n')
if not wait_roll(mav, -150, accuracy=90): if not wait_roll(mav, -150, accuracy=90):
mavproxy.send('rc 1 1500\n')
return False return False
if not wait_roll(mav, 150, accuracy=90): if not wait_roll(mav, 150, accuracy=90):
mavproxy.send('rc 1 1500\n')
return False return False
if not wait_roll(mav, 0, accuracy=90): if not wait_roll(mav, 0, accuracy=90):
mavproxy.send('rc 1 1500\n')
return False return False
count -= 1 count -= 1

View File

@ -84,29 +84,31 @@ def wait_groundspeed(mav, gs_min, gs_max, timeout=30):
def wait_roll(mav, roll, accuracy, timeout=30): def wait_roll(mav, roll, accuracy, timeout=30):
'''wait for a given roll in degrees''' '''wait for a given roll in degrees'''
tstart = time.time() tstart = time.time()
print("Waiting for roll of %u" % roll) print("Waiting for roll of %d at %s" % (roll, time.ctime()))
while time.time() < tstart + timeout: while time.time() < tstart + timeout:
m = mav.recv_match(type='ATTITUDE', blocking=True) m = mav.recv_match(type='ATTITUDE', blocking=True)
p = math.degrees(m.pitch)
r = math.degrees(m.roll) r = math.degrees(m.roll)
print("Roll %u" % r) print("Roll %d Pitch %d" % (r, p))
if math.fabs(r - roll) <= accuracy: if math.fabs(r - roll) <= accuracy:
print("Attained roll %u" % roll) print("Attained roll %d" % roll)
return True return True
print("Failed to attain roll %u" % roll) print("Failed to attain roll %d" % roll)
return False return False
def wait_pitch(mav, pitch, accuracy, timeout=30): def wait_pitch(mav, pitch, accuracy, timeout=30):
'''wait for a given pitch in degrees''' '''wait for a given pitch in degrees'''
tstart = time.time() tstart = time.time()
print("Waiting for pitch of %u" % pitch) print("Waiting for pitch of %u at %s" % (pitch, time.ctime()))
while time.time() < tstart + timeout: while time.time() < tstart + timeout:
m = mav.recv_match(type='ATTITUDE', blocking=True) m = mav.recv_match(type='ATTITUDE', blocking=True)
r = math.degrees(m.pitch) p = math.degrees(m.pitch)
print("Pitch %u" % r) r = math.degrees(m.roll)
print("Pitch %d Roll %d" % (p, r))
if math.fabs(r - pitch) <= accuracy: if math.fabs(r - pitch) <= accuracy:
print("Attained pitch %u" % pitch) print("Attained pitch %d" % pitch)
return True return True
print("Failed to attain pitch %u" % pitch) print("Failed to attain pitch %d" % pitch)
return False return False
@ -228,4 +230,4 @@ def sim_location(mav):
'''return current simulator location''' '''return current simulator location'''
from pymavlink import mavutil from pymavlink import mavutil
m = mav.recv_match(type='SIMSTATE', blocking=True) m = mav.recv_match(type='SIMSTATE', blocking=True)
return mavutil.location(m.lat*1.0e-7, m.lng*1.0e-7, 0, math.degrees(m.yaw)) return mavutil.location(m.lat*1.0e-7, m.lng*1.0e-7, 0, math.degrees(m.yaw))