Skip to content
Snippets Groups Projects
Commit fe9705ad authored by Jason Short's avatar Jason Short
Browse files

Checking for climb rate

parent 01420440
No related branches found
No related tags found
Loading
...@@ -63,12 +63,18 @@ def current_location(mav): ...@@ -63,12 +63,18 @@ def current_location(mav):
mav.messages['VFR_HUD'].alt) mav.messages['VFR_HUD'].alt)
def wait_altitude(mav, alt_min, alt_max, timeout=30): def wait_altitude(mav, alt_min, alt_max, timeout=30):
climb_rate = 0
previous_alt = 0
'''wait for a given altitude range''' '''wait for a given altitude range'''
tstart = time.time() tstart = time.time()
print("Waiting for altitude between %u and %u" % (alt_min, alt_max)) print("Waiting for altitude between %u and %u" % (alt_min, alt_max))
while time.time() < tstart + timeout: while time.time() < tstart + timeout:
m = mav.recv_match(type='VFR_HUD', blocking=True) m = mav.recv_match(type='VFR_HUD', blocking=True)
print("Altitude %u" % m.alt) climb_rate = m.alt - previous_alt
previous_alt = m.alt
print("Altitude %u, rate: %u" % (m.alt, climb_rate))
if abs(climb_rate) > 0:
tstart = time.time();
if m.alt >= alt_min and m.alt <= alt_max: if m.alt >= alt_min and m.alt <= alt_max:
return True return True
print("Failed to attain altitude range") print("Failed to attain altitude range")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment