Skip to the content
FixTheRobot Explore Robotics / UAV / Module 6 / M6-L7

UAV Systems Engineering · M6-L7 · Hands-on lab (runs on your machine)

Analyze flight logs

Flight logs are the vehicle’s black box. Learn to read one methodically.

  • UAV Software and Flight-Controller Integration
  • Implementation-specific
  • About 60 minutes

What you will do

You will analyse a log from your SITL flight with pyulog and a plotting library, and optionally with Flight Review. Privacy note: logs uploaded to the public Flight Review service can be public; do not upload logs of real flights you consider sensitive.

Before you start

  • A ULog file from an earlier lab.
  • Python with pyulog, numpy and matplotlib installed (pip install pyulog).
  • Lesson M6-T13 (flight logs and debugging).

Steps

  1. List the file contents: ulog_info flight.ulg. Note the duration, parameters and the list of topics with their message counts.
  2. Export topics to CSV: ulog2csv flight.ulg -m vehicle_local_position,vehicle_status, or read them in Python.
  3. Plot measured local position against the setpoint (from trajectory_setpoint) and compute RMS and maximum tracking error.
  4. Plot the arming state and navigation state over time to mark mode changes.
  5. Inspect the estimator status/innovation topics for your version (list the topics first) and find the maximum innovation test ratios.
from pyulog import ULog
import numpy as np

log = ULog("flight.ulg")
pos = log.get_dataset("vehicle_local_position").data
sp  = log.get_dataset("trajectory_setpoint").data
t_pos = pos["timestamp"] * 1e-6
t_sp  = sp["timestamp"] * 1e-6
x_sp = np.interp(t_pos, t_sp, sp["position[0]"])
err = np.hypot(pos["x"] - x_sp, 0)     # extend to y and z, ignoring NaN setpoints
print("rows:", len(t_pos), "RMS x error:", np.sqrt(np.nanmean(err**2)))
Reading a ULog with pyulog. Field names vary with message versions: print dataset.data.keys() first.

Report

  • A timeline with arming, mode changes and any failsafe events.
  • Tracking error statistics per leg of the mission.
  • The estimator’s innovation statistics and an assessment of whether the filter looked consistent.
  • Three questions the log cannot answer and what extra logging would answer them.

How to know it worked

  • Plots of setpoint against measurement with error statistics.
  • A timeline of modes and events.
  • A written assessment of estimator health from innovation data.

If it does not work

Troubleshooting
SymptomLikely causeWhat to check
KeyError on a fieldField names differ by versionPrint dataset.data.keys() and adapt
Setpoint log emptyTopic not logged or not streamedCheck the logger configuration and that offboard setpoints were being published
Time axes do not alignDifferent topic ratesInterpolate onto a common time base

References

Record your progress

Saved in this browser. This lab runs on your own machine, so the site cannot check it for you.