ardupilot/Tools/LogAnalyzer/tests/TestBrownout.py
Andrew Chapman 36e480483f LogAnalyzer: Initial commit for discussion
A lot of this is still stub code, but far enough along for discussion
and feedback. Some good example tests are TestVibration and TestBrownout

datatypes handled correctly now (previsouly all read as floats), added
flag to skip bad input lines, now prints some general log info (size,
duration, etc), added some basic performance timing,
2014-06-24 15:07:45 +10:00

35 lines
1.3 KiB
Python

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):
self.name = "Brownout"
def run(self, logdata):
self.result = TestResult()
self.result.status = TestResult.StatusType.PASS
# 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
evData = logdata.channels["EV"]["Id"]
orderedEVData = collections.OrderedDict(sorted(evData.dictData.items(), key=lambda t: t[0]))
isArmed = False
for line,ev in orderedEVData.iteritems():
if ev == 10:
isArmed = True
elif ev == 11:
isArmed = False
# check for relative altitude at end
if "CTUN" in logdata.channels and "BarAlt" in logdata.channels["CTUN"]:
finalAlt = logdata.channels["CTUN"]["BarAlt"].getNearestValue(logdata.lineCount, lookForwards=False)
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