mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-30 04:06:33 +08:00
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:
@@ -1166,7 +1166,7 @@ def analyse_ekf(estimator_status, ekf2_innovations, sensor_preflight, check_leve
|
|||||||
}
|
}
|
||||||
# generate test metadata
|
# generate test metadata
|
||||||
# reduction of innovation message data
|
# 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
|
# Output Observer Tracking Errors
|
||||||
test_results['output_obs_ang_err_median'][0] = np.median(
|
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])
|
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(
|
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])
|
ekf2_innovations['output_tracking_error[2]'][innov_late_start_index:innov_early_end_index + 1])
|
||||||
# reduction of status message data
|
# reduction of status message data
|
||||||
if (early_end_index > (late_start_index + 100)):
|
if (early_end_index > (late_start_index + 50)):
|
||||||
# IMU vibration checks
|
# IMU vibration checks
|
||||||
temp = np.amax(estimator_status['vibe[0]'][late_start_index:early_end_index])
|
temp = np.amax(estimator_status['vibe[0]'][late_start_index:early_end_index])
|
||||||
if (temp > 0.0):
|
if (temp > 0.0):
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ parser.add_argument("directory_path")
|
|||||||
parser.add_argument('-o', '--overwrite', action='store_true',
|
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'
|
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.')
|
'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):
|
def is_valid_directory(parser, arg):
|
||||||
if os.path.isdir(arg):
|
if os.path.isdir(arg):
|
||||||
@@ -26,8 +29,8 @@ args = parser.parse_args()
|
|||||||
ulog_directory = args.directory_path
|
ulog_directory = args.directory_path
|
||||||
print("\n"+"analysing the .ulg files in "+ulog_directory)
|
print("\n"+"analysing the .ulg files in "+ulog_directory)
|
||||||
|
|
||||||
# get all the ulog files found in the specified directory
|
# get all the ulog files found in the specified directory and in subdirectories
|
||||||
ulog_files = glob.glob(os.path.join(ulog_directory, '*.ulg'))
|
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
|
# 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.'
|
# a corresponding .pdf file exists.'
|
||||||
@@ -38,4 +41,7 @@ if not args.overwrite:
|
|||||||
# analyse all ulog files
|
# analyse all ulog files
|
||||||
for ulog_file in ulog_files:
|
for ulog_file in ulog_files:
|
||||||
print("\n"+"loading "+ulog_file +" for analysis")
|
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))
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os, sys
|
||||||
|
|
||||||
from pyulog import *
|
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
|
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.')
|
help='Whether to only analyse and not plot the summaries for developers.')
|
||||||
parser.add_argument('--check-level-thresholds', type=str, default=None,
|
parser.add_argument('--check-level-thresholds', type=str, default=None,
|
||||||
help='The csv file of fail and warning test thresholds for analysis.')
|
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):
|
def is_valid_directory(parser, arg):
|
||||||
if os.path.isdir(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
|
# perform the ekf analysis
|
||||||
test_results = analyse_ekf(
|
test_results = analyse_ekf(
|
||||||
estimator_status_data, ekf2_innovations_data, sensor_preflight_data,
|
estimator_status_data, ekf2_innovations_data, sensor_preflight_data,
|
||||||
check_levels, plot=not args.no_plots, output_plot_filename=args.filename + ".pdf")
|
check_levels, plot=not args.no_plots, output_plot_filename=args.filename + ".pdf",
|
||||||
|
late_start_early_ending=not args.no_sensor_safety_margin)
|
||||||
# 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')
|
|
||||||
|
|
||||||
# write metadata to a .csv file
|
# write metadata to a .csv file
|
||||||
with open(args.filename + ".mdat.csv", "w") as 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:
|
if not args.no_plots:
|
||||||
print('Plots saved to {:s}.pdf'.format(args.filename))
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user