|
|
|
@ -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)) |
|
|
|
|