Main Content

Add Custom Functions in Flight Log Analyzer App to Detect Region of Interest for Analysis

This example shows how to create and add custom functions in the Flight Log Analyzer app to detect a specific region or point of interest for further analysis. These functions can be useful when analyzing several log files or a single large log file.

For example, if a well-controlled flight has good tracking of the desired roll, pitch, and yaw angles, you can visualize them by plotting the desired versus the estimated angles. You can use a custom function to track the difference and show the regions where the difference is more than the threshold value. You can further investigate those regions by examining other logged signals like actuator outputs and EKF estimates at those instances.

Open Flight Log Analyzer App

In the Apps tab, under Robotics and Autonomous Systems, select Flight Log Analyzer.

Alternatively, you can use the flightLogAnalyzer command from the MATLAB® command prompt.

Import ULOG File

Load a ULOG file into the workspace.

ulg = ulogreader("flight.ulg")
ulg = 
  ulogreader with properties:

            FileName: "flight.ulg"
           StartTime: 00:00:00.176000
             EndTime: 00:02:15.224000
     AvailableTopics: [51x5 table]
    DropoutIntervals: [0x2 duration]

On the Flight Log Analyzer app toolstrip, select Import > From Workspace. In the Log Data section of the Import flight log signal mapping and log data from workspace dialog box, select the ulogreader object ulg and click Import.

Add Annotation Function

To add a custom function to the Flight Log Analyzer app:

  1. In the Annotate section of the app toolstrip, click Add Function.

  2. In the dialog box, specify the Function name as ComputeTrackingError.

  3. Specify the Label type as ROI.

  4. Click OK.

The ComputeTrackingError function appears in the gallery in the Annotate section, because the function has already been provided with this example and is on the MATLAB path.

If the function does not exist on the MATLAB path, the app suggests to create a new function and opens a function template in the MATLAB editor. If the function is at a different location, you must add the location to the MATLAB path.

The function can access the flightLogSignalMapping object, the complete flight log data, the selected signals, and the additional optional arguments from the app.

Run Annotation Function

Run the ComputeTrackingError annotation function to find the regions with a tracking error greater than the threshold value.

  1. In the Annotate gallery, click ComputeTrackingError.

  2. In the dialog box, select the required signals from the Signals pane.

  3. Expand AttitudeEuler and select Roll.

  4. Expand AttitudeTargetEuler and select RollTarget.

  5. Click Add Signals. The added signals are listed in the Signal Order Preview pane.

  6. For varargin, specify a threshold value of 0.35.

  7. Click Run.

  8. Repeat these steps, but selecting Pitch and PitchTarget or Yaw and YawTarget, respectively.

You can rearrange the order of the signals passed to the function using Move Signals Down and Move Signals Up. You can also remove the signals using Remove Signals.

Create Figures and Plots

Create custom Timeseries plots to compare the estimated roll, pitch, and yaw angles against their corresponding desired angles.

  1. In the Plot section of the app toolstrip, click Add Figure to add an empty figure to the plotting pane.

  2. In the Custom Plots section of the plot gallery, select Timeseries.

  3. In the Details pane, rename the plot to Roll (estimated vs setpoint).

  4. In the Signals pane, click Add Signal twice to add two signals.

  5. Double-click the Y-Axis column of the first signal and, in the Signal Browser window, type Roll in the Search box. Expand AttitudeEuler and select Roll. Then, click Update.

  6. Double-click the Y-Axis column of the second signal and, in the Signal Browser window, type RollTarget in the Search box. Expand AttitudeTargetEuler and select RollTarget. Then, click Update.

  7. Rename the first signal to Estimated Roll and the second signal to Setpoint Roll. To rename a signal, double-click its entry in the Signal Name column and type the new name.

  8. Repeat the steps 2 to 7, but selecting Pitch and PitchTarget or Yaw and YawTarget, respectively.

Annotate Plots

  1. In the Figures pane, select the plot on which you want to see the detected region of interest.

  2. In the Annotation pane, select the ROIs to highlight the regions on the plot with tracking error greater than the specified threshold value.

  3. To rename the default annotation label, right-click the label and select Rename Label. Then, type the new label name.

Export Signals and Annotations as Labeled Signal Set

Export the annotations and selected signals as a labeledSignalSet object.

  1. In the Export section of the app toolstrip, click Export > Export to LabeledSignalSet.

  2. Specify a variable name for the labeledSignalSet object.

  3. Specify a name for the flight log label.

  4. Select at least one signal to export to the labeledSignalSet object.

  5. Select the annotations to export.

  6. Click Export.

You can open the labeledSignalSet object in the workspace or in the Signal Labeler app. You can use the time-frequency plots for analysis or to correct some of the annotations, which you can then be use for machine learning-based anomaly detection.