2014-01-27 02:38:57 -04:00
|
|
|
from LogAnalyzer import Test,TestResult
|
|
|
|
import DataflashLog
|
|
|
|
|
|
|
|
import collections
|
|
|
|
|
|
|
|
class TestBrownout(Test):
|
|
|
|
'''test for a log that has been truncated in flight'''
|
|
|
|
|
|
|
|
def __init__(self):
|
2014-06-27 20:11:23 -03:00
|
|
|
Test.__init__(self)
|
2014-01-27 02:38:57 -04:00
|
|
|
self.name = "Brownout"
|
|
|
|
|
2014-03-03 13:46:17 -04:00
|
|
|
def run(self, logdata, verbose):
|
2014-01-27 02:38:57 -04:00
|
|
|
self.result = TestResult()
|
2014-06-15 18:35:14 -03:00
|
|
|
self.result.status = TestResult.StatusType.GOOD
|
2014-01-27 02:38:57 -04:00
|
|
|
|
2014-02-22 15:36:30 -04:00
|
|
|
if "EV" in logdata.channels:
|
|
|
|
# step through the arm/disarm events in order, to see if they're symmetrical
|
|
|
|
# note: it seems landing detection isn't robust enough to rely upon here, so we'll only consider arm+disarm, not takeoff+land
|
|
|
|
isArmed = False
|
2014-02-23 10:20:18 -04:00
|
|
|
for line,ev in logdata.channels["EV"]["Id"].listData:
|
2014-02-22 15:36:30 -04:00
|
|
|
if ev == 10:
|
|
|
|
isArmed = True
|
|
|
|
elif ev == 11:
|
|
|
|
isArmed = False
|
|
|
|
|
|
|
|
if "CTUN" not in logdata.channels:
|
|
|
|
self.result.status = TestResult.StatusType.UNKNOWN
|
|
|
|
self.result.statusMessage = "No CTUN log data"
|
|
|
|
return
|
2014-01-27 02:38:57 -04:00
|
|
|
|
|
|
|
# check for relative altitude at end
|
|
|
|
if "CTUN" in logdata.channels and "BarAlt" in logdata.channels["CTUN"]:
|
2014-02-22 15:36:30 -04:00
|
|
|
(finalAlt,finalAltLine) = logdata.channels["CTUN"]["BarAlt"].getNearestValue(logdata.lineCount, lookForwards=False)
|
2014-01-27 02:38:57 -04:00
|
|
|
|
|
|
|
finalAltMax = 3.0 # max alt offset that we'll still consider to be on the ground
|
|
|
|
if isArmed and finalAlt > finalAltMax:
|
|
|
|
self.result.status = TestResult.StatusType.FAIL
|
|
|
|
self.result.statusMessage = "Truncated Log? Ends while armed at altitude %.2fm" % finalAlt
|