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.
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,numpyandmatplotlibinstalled (pip install pyulog). - Lesson M6-T13 (flight logs and debugging).
Steps
- List the file contents:
ulog_info flight.ulg. Note the duration, parameters and the list of topics with their message counts. - Export topics to CSV:
ulog2csv flight.ulg -m vehicle_local_position,vehicle_status, or read them in Python. - Plot measured local position against the setpoint (from
trajectory_setpoint) and compute RMS and maximum tracking error. - Plot the arming state and navigation state over time to mark mode changes.
- 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)))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
| Symptom | Likely cause | What to check |
|---|---|---|
| KeyError on a field | Field names differ by version | Print dataset.data.keys() and adapt |
| Setpoint log empty | Topic not logged or not streamed | Check the logger configuration and that offboard setpoints were being published |
| Time axes do not align | Different topic rates | Interpolate 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.