mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-24 17:48:35 -04:00
LogAnalyzer: balance/twist initial commit
This commit is contained in:
parent
28b98a170b
commit
0955284d7e
@ -4,7 +4,6 @@ import DataflashLog
|
|||||||
|
|
||||||
class TestBalanceTwist(Test):
|
class TestBalanceTwist(Test):
|
||||||
'''test for badly unbalanced copter, including yaw twist'''
|
'''test for badly unbalanced copter, including yaw twist'''
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Test.__init__(self)
|
Test.__init__(self)
|
||||||
self.name = "Balance/Twist"
|
self.name = "Balance/Twist"
|
||||||
@ -17,4 +16,47 @@ class TestBalanceTwist(Test):
|
|||||||
self.result.status = TestResult.StatusType.NA
|
self.result.status = TestResult.StatusType.NA
|
||||||
return
|
return
|
||||||
|
|
||||||
# TODO: implement copter test for unbalanced or twisted copter frame
|
self.result.status = TestResult.StatusType.UNKNOWN
|
||||||
|
if not "RCOU" in logdata.channels:
|
||||||
|
return
|
||||||
|
|
||||||
|
ch = []
|
||||||
|
|
||||||
|
for i in range(8):
|
||||||
|
if "Chan"+`(i+1)` in logdata.channels["RCOU"]:
|
||||||
|
ch.append(map(lambda x: x[1], logdata.channels["RCOU"]["Chan"+`(i+1)`].listData))
|
||||||
|
elif "Ch"+`(i+1)` in logdata.channels["RCOU"]:
|
||||||
|
ch.append(map(lambda x: x[1], logdata.channels["RCOU"]["Ch"+`(i+1)`].listData))
|
||||||
|
|
||||||
|
ch = zip(*ch)
|
||||||
|
num_channels = 0
|
||||||
|
for i in range(len(ch)):
|
||||||
|
ch[i] = filter(lambda x: x != 0, ch[i])
|
||||||
|
if num_channels < len(ch[i]):
|
||||||
|
num_channels = len(ch[i])
|
||||||
|
|
||||||
|
if num_channels < 2:
|
||||||
|
return
|
||||||
|
|
||||||
|
min_throttle = logdata.parameters["RC3_MIN"] + logdata.parameters["THR_MIN"] / (logdata.parameters["RC3_MAX"]-logdata.parameters["RC3_MIN"])/1000.0
|
||||||
|
ch = filter(lambda x:sum(x)/num_channels > min_throttle, ch)
|
||||||
|
|
||||||
|
if len(ch) == 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
avg_all = map(lambda x:sum(x)/num_channels,ch)
|
||||||
|
avg_all = sum(avg_all)/len(avg_all)
|
||||||
|
avg_ch = []
|
||||||
|
for i in range(num_channels):
|
||||||
|
avg = map(lambda x: x[i],ch)
|
||||||
|
avg = sum(avg)/len(avg)
|
||||||
|
avg_ch.append(avg)
|
||||||
|
|
||||||
|
self.result.statusMessage = "Motor channel averages = %s\nAverage motor output = %.0f\nDifference between min and max motor averages = %.0f" % (str(avg_ch),avg_all,abs(min(avg_ch)-max(avg_ch)))
|
||||||
|
|
||||||
|
self.result.status = TestResult.StatusType.GOOD
|
||||||
|
|
||||||
|
if abs(min(avg_ch)-max(avg_ch)) > 75:
|
||||||
|
self.result.status = TestResult.StatusType.WARN
|
||||||
|
if abs(min(avg_ch)-max(avg_ch)) > 150:
|
||||||
|
self.result.status = TestResult.StatusType.FAIL
|
||||||
|
Loading…
Reference in New Issue
Block a user