Browse Source

autotest: tweak plane autotest debugging

master
Andrew Tridgell 11 years ago
parent
commit
8f558609a9
  1. 6
      Tools/autotest/arduplane.py
  2. 22
      Tools/autotest/common.py

6
Tools/autotest/arduplane.py

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

22
Tools/autotest/common.py

@ -84,29 +84,31 @@ def wait_groundspeed(mav, gs_min, gs_max, timeout=30): @@ -84,29 +84,31 @@ def wait_groundspeed(mav, gs_min, gs_max, timeout=30):
def wait_roll(mav, roll, accuracy, timeout=30):
'''wait for a given roll in degrees'''
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:
m = mav.recv_match(type='ATTITUDE', blocking=True)
p = math.degrees(m.pitch)
r = math.degrees(m.roll)
print("Roll %u" % r)
print("Roll %d Pitch %d" % (r, p))
if math.fabs(r - roll) <= accuracy:
print("Attained roll %u" % roll)
print("Attained roll %d" % roll)
return True
print("Failed to attain roll %u" % roll)
print("Failed to attain roll %d" % roll)
return False
def wait_pitch(mav, pitch, accuracy, timeout=30):
'''wait for a given pitch in degrees'''
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:
m = mav.recv_match(type='ATTITUDE', blocking=True)
r = math.degrees(m.pitch)
print("Pitch %u" % r)
p = math.degrees(m.pitch)
r = math.degrees(m.roll)
print("Pitch %d Roll %d" % (p, r))
if math.fabs(r - pitch) <= accuracy:
print("Attained pitch %u" % pitch)
print("Attained pitch %d" % pitch)
return True
print("Failed to attain pitch %u" % pitch)
print("Failed to attain pitch %d" % pitch)
return False
@ -228,4 +230,4 @@ def sim_location(mav): @@ -228,4 +230,4 @@ def sim_location(mav):
'''return current simulator location'''
from pymavlink import mavutil
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))

Loading…
Cancel
Save