Load ULog and PX4 files in Python
PX4 is the leading software standard for drones and unmanned aerial vehicles (UAVs). PX4 provides a platform for controlling autonomous flight and navigation systems.
ULog is a binary log file format used by the PX4 autopilot system for recording flight data. It captures various flight parameters such as sensor readings, GPS data, battery status, and actuator outputs.
In Nominal, ULog data is used for post-flight analysis, debugging, and performance benchmarks. This guide uses flight logs from the PX4 community hub to demonstrate an automated pipeline for ingesting ULog files into Nominal.
Download flight logs
For convenience, Nominal hosts sample test data on Hugging Face. To download the sample data for this guide, copy-paste the snippet below.
(Make sure to first install huggingface_hub with pip3 install huggingface_hub
).
Convert ULog to CSV
ulog2csv
converts the PX4 ULog file to a folder of CSV logs:
List all CSV flight logs
Depending on the flight, the ULog-to-CSV converter will output ~50 CSV flight logs. To get an idea of what these log files are, we’ll print each of their file names.
~50 CSV flight log names are printed.
Inspect PX4 GPS log
Let’s inspect a single log file (..log_vehicle_gps_position_0.csv
). Note that the timestamp
column is common across log files and always in relative microseconds, meaning microseconds from the start of the flight or whenever the sensor began recording.
timestamp | time_utc_usec | lat | lon | alt | alt_ellipsoid |
---|---|---|---|---|---|
i64 | i64 | i64 | i64 | i64 | i64 |
96689774 | 1581933170999989 | 473566110 | 85190396 | 423805 | 471145 |
96890716 | 1581933171199988 | 473566109 | 85190398 | 423779 | 471119 |
97089357 | 1581933171399988 | 473566107 | 85190398 | 423756 | 471096 |
97289265 | 1581933171599988 | 473566105 | 85190398 | 423687 | 471028 |
97490058 | 1581933171799988 | 473566103 | 85190400 | 423665 | 471005 |
Let’s plot the recorded latitude vs longitude from the GPS sensor.
Upload PX4 GPS log
Connect to Nominal
Get your Nominal API token from your User settings page.
See the Quickstart for more details on connecting to Nominal from Python.
Upload to Nominal
After upload, navigate to Nominal’s Datasets page (login required). You’ll see your CSV at the top!
Create PX4 log lookup table
The below script creates a dataframe with each log file’s path, start time, and end time.
Some log files don’t have valid start and end times - we’ll remove these rows from the dataframe.
Finally, we’ll plot all of the log start and end times to identify any outliers.
Each log’s start and end times vary slightly but are generally uniform. No sensors started mid-flight or stopped long after landing.
Extract absolute flight time
To get an absolute flight start time, we’ll use the time_utc_usec
column from the GPS sensor log file.
Create PX4 log run
In Nominal, Runs are containers of multimodal test data - including Datasets, Videos, Logs, and database connections.
To see your organization’s latest Runs, head over to the Runs page
We’ll use the create_run()
routine to create a Run with the flight start and end times that we identified above.
If you head over to the Runs page on Nominal (login required), you’ll see the “PX4 single quadrotor flight” at the top:
Bulk upload all PX4 logs
To upload all ~50 PX4 log files to the quadrotor run, we’ll iterate through the lookup table that we created and validated above.
For each row of the lookup table, we’ll call upload_csv()
to upload the log file and Run.add_dataset()
to associate the log file with the run.
On Nominal, navigate from the Runs page to the Data sources tab of the quadrotor run. You should see the ~50 uploaded log files.
Create a workbook
Now that all of the flight data is organized as a test Run on Nominal, it can be collaboratively visualized, analyzed, and benchmarked as a reference for future flights. See the below Nominal Workbook for example (login required).
Appendix
Inspect ULog metadata
Run the ulog_info
command to extract high-level log file parameters such as the flight computer RTOS and version.