The sdlog2 app serves the purpose to log flight data onto the SD card on the FMU. The log file format is compatible with the APM binary log, but sdlog2 uses the mandatory message TIME to write timestamps.


Everytime sdlog2 starts logging, it creates a new directory in the log folder of the SD card. The folder name is based on the current date if the option -t is set and a GPS timestamp is available (e.g. log/2014-01-19). Otherwise, it is called sessXXX where XXX represents a sequential number. The file name is created in a similar manner by using the current time (e.g. log/2014-01-19/19_37_52.bin) if possible and enabled using the -t options, otherwise the file is called log.XXX.bin, again using a sequential number.

Logging starts depending on the given options, either when the app is started, the system is armed, or via mavlink command.

  usage: sdlog2 {start|stop|status} [-r <log rate>] [-b <buffer size>] -e -a
          -r      Log rate in Hz, 0 means unlimited rate
          -b      Log buffer size in KBytes, default is 8
          -e      Enable logging on app start (if not, can be started by command)
          -a      Log only when armed (can be still overriden by command)
          -t      Use GPS timestamps to create folder and file names

The logging performance depends on the speed of the used microSD card. Use a high-quality card to avoid skipped data. Running sdlog2 at full rate (i.e. without -r option) can cause significant CPU load, without influencing the flight performance negatively though. However, the desired full rate might not be met and the logger will start to skip messages.

Logging Start

Under normal circumstances logging starts with arming the vehicle, as only active flight are interesting for analysis. To launch logging manually, type these commands on the console:

sdlog2 stop
sdlog2 start -t -r 200 -e -b 16

Stop logging again by issuing:

sdlog2 stop

Analyzing Logs


To view and analyze logs, the GUI tool FlightPlot can be used. It can read the binary log files generated by sdlog2 without converting.

You can also use the mavgraph tool contained in pymavlink to generate plots.

CSV / Matlab: Converting Logs to CSV

To read the binary file and convert it to CSV, the python tool can be used. The same directory contains a Matlab script which runs the converter and plots a number of core messages.

E.g. to read TIME and IMU messages, BaroAlt and BaroTemp fields from SENS message use the following command:

  python log001.px4log -t TIME -m TIME -m IMU -m SENS.BaroAlt,BaroTemp

To create CSV just redirect output to file:

  python log001.px4log -t TIME -m TIME -m IMU -m SENS.BaroAlt,BaroTemp > log.csv

Columns in CSV file will have the same order as arguments. Option -t significantly reduces duplicate data on output, and should be used always for logs generated by sdlog2. But don't use it for original APM logs.

Example Message Types

  • TIME - Time stamp
  • ATT - Vehicle attitude
  • ATSP - Vehicle attitude setpoint
  • IMU - IMU sensors
  • SENS - Other sensors
  • LPOS - Local position estimate
  • LPSP - Local position setpoint
  • GPS - GPS position
  • ATTC - Attitude controls (actuator_0 output)
  • STAT - Vehicle state
  • RC - RC input channels
  • OUT0 - Actuator_0 output
  • AIRS - Airspeed
  • ARSP - Attitude rate setpoint
  • FLOW - Optical flow
  • GPOS - Global position estimate
  • GPSP - Global position setpoint
  • ESC - ESC state
  • GVSP - Global velocity setpoint

Message types can be changed sometimes. To find out actual list of messages contained in log file use the following command:

  python log001.bin -v

Or use FlightPlot to see it.


sdlog2 has a buffer between listening messages and writing log to SD card to avoid suspending critical applications in flight during heavy IO operations. If the buffer is overflowed at some point, some log messages will be skipped. Count of the skipped messages can be checked via console with sdlog2 status command. Also statistics printed on closing log file, i.e. on disarm when -a option used. If skipped messages count is not zero, it can be fixed with increasing buffer size with -b option. The following command will set log buffer size to 16KiB instead of default 8KiB:

sdlog2 start -t -r 100 -e -b 16

Load testing

To test the microSD bandwidth, start the app with 200 Hz rate and 32 KB buffer, and the -e flag to log immediately.

# First stop the already running instance
sdlog2 stop
sdlog2 start -t -r 200 -e -b 32
# Run the perf command to see the induced sdlog2 load:
# (NOTE: the performance counter only exists during logging)
# Or run top
# Stop the app to clean up FDs and filesystem
sdlog2 stop

Sample Logs

Translations of this page:

Quick Links

QR Code: URL of current page