ecl-ekf tools: set exit code to -1 for failed analysis, pipe args

- process_log_data: exit with code -1 if whole system analysis fails
- batch_process_logdata and process_log_data: pipe sensor safety
margin argument to the arguments of the superseeding scripts
- reduce minimum flight length for analysis to 50 samples
This commit is contained in:
johannes
2018-06-15 17:06:38 +02:00
committed by Daniel Agar
parent effeae93cc
commit 78d8061aaf
3 changed files with 27 additions and 16 deletions
+2 -2
View File
@@ -1166,7 +1166,7 @@ def analyse_ekf(estimator_status, ekf2_innovations, sensor_preflight, check_leve
}
# generate test metadata
# reduction of innovation message data
if (innov_early_end_index > (innov_late_start_index + 100)):
if (innov_early_end_index > (innov_late_start_index + 50)):
# Output Observer Tracking Errors
test_results['output_obs_ang_err_median'][0] = np.median(
ekf2_innovations['output_tracking_error[0]'][innov_late_start_index:innov_early_end_index + 1])
@@ -1175,7 +1175,7 @@ def analyse_ekf(estimator_status, ekf2_innovations, sensor_preflight, check_leve
test_results['output_obs_pos_err_median'][0] = np.median(
ekf2_innovations['output_tracking_error[2]'][innov_late_start_index:innov_early_end_index + 1])
# reduction of status message data
if (early_end_index > (late_start_index + 100)):
if (early_end_index > (late_start_index + 50)):
# IMU vibration checks
temp = np.amax(estimator_status['vibe[0]'][late_start_index:early_end_index])
if (temp > 0.0):
+9 -3
View File
@@ -14,6 +14,9 @@ parser.add_argument("directory_path")
parser.add_argument('-o', '--overwrite', action='store_true',
help='Whether to overwrite an already analysed file. If a file with .pdf extension exists for a .ulg'
'file, the log file will be skipped from analysis unless this flag has been set.')
parser.add_argument('--no-sensor-safety-margin', action='store_true',
help='Whether to not cut-off 5s after take-off and 5s before landing '
'(for certain sensors that might be influence by proximity to ground).')
def is_valid_directory(parser, arg):
if os.path.isdir(arg):
@@ -26,8 +29,8 @@ args = parser.parse_args()
ulog_directory = args.directory_path
print("\n"+"analysing the .ulg files in "+ulog_directory)
# get all the ulog files found in the specified directory
ulog_files = glob.glob(os.path.join(ulog_directory, '*.ulg'))
# get all the ulog files found in the specified directory and in subdirectories
ulog_files = glob.glob(os.path.join(ulog_directory, '**/*.ulg'), recursive=True)
# remove the files already analysed unless the overwrite flag was specified. A ulog file is consired to be analysed if
# a corresponding .pdf file exists.'
@@ -38,4 +41,7 @@ if not args.overwrite:
# analyse all ulog files
for ulog_file in ulog_files:
print("\n"+"loading "+ulog_file +" for analysis")
os.system("python process_logdata_ekf.py '{}'".format(ulog_file))
if args.no_sensor_safety_margin:
os.system("python process_logdata_ekf.py {} --no-sensor-safety-margin".format(ulog_file))
else:
os.system("python process_logdata_ekf.py {}".format(ulog_file))
+16 -11
View File
@@ -3,11 +3,11 @@
from __future__ import print_function
import argparse
import os
import os, sys
from pyulog import *
from analyse_logdata_ekf import *
from analyse_logdata_ekf import analyse_ekf
"""
Performs a health assessment on the ecl EKF navigation estimator data contained in a an ULog file
@@ -21,6 +21,9 @@ parser.add_argument('--no-plots', action='store_true',
help='Whether to only analyse and not plot the summaries for developers.')
parser.add_argument('--check-level-thresholds', type=str, default=None,
help='The csv file of fail and warning test thresholds for analysis.')
parser.add_argument('--no-sensor-safety-margin', action='store_true',
help='Whether to not cut-off 5s after take-off and 5s before landing '
'(for certain sensors that might be influence by proximity to ground).')
def is_valid_directory(parser, arg):
if os.path.isdir(arg):
@@ -73,15 +76,8 @@ print('Using test criteria loaded from {:s}'.format(check_level_dict_filename))
# perform the ekf analysis
test_results = analyse_ekf(
estimator_status_data, ekf2_innovations_data, sensor_preflight_data,
check_levels, plot=not args.no_plots, output_plot_filename=args.filename + ".pdf")
# print master test status to console
if (test_results['master_status'][0] == 'Pass'):
print('No anomalies detected')
elif (test_results['master_status'][0] == 'Warning'):
print('Minor anomalies detected')
elif (test_results['master_status'][0] == 'Fail'):
print('Major anomalies detected')
check_levels, plot=not args.no_plots, output_plot_filename=args.filename + ".pdf",
late_start_early_ending=not args.no_sensor_safety_margin)
# write metadata to a .csv file
with open(args.filename + ".mdat.csv", "w") as file:
@@ -99,3 +95,12 @@ print('Test results written to {:s}.mdat.csv'.format(args.filename))
if not args.no_plots:
print('Plots saved to {:s}.pdf'.format(args.filename))
# print master test status to console
if (test_results['master_status'][0] == 'Pass'):
print('No anomalies detected')
elif (test_results['master_status'][0] == 'Warning'):
print('Minor anomalies detected')
elif (test_results['master_status'][0] == 'Fail'):
print('Major anomalies detected')
sys.exit(-1)