Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Ardupilot/ardupilot/llms.txt
Use this file to discover all available pages before exploring further.
AP_Logger is ArduPilot’s onboard logging system. It writes a continuous binary stream of structured messages to an SD card (or internal flash on boards without an SD slot), producing .bin files that can be analysed offline with MAVExplorer, Mission Planner, or the pymavlink toolchain. Logging is the primary way to diagnose flight problems, tune controllers, and replay EKF data after a flight.
Binary .bin Format
Log files use a compact binary format with self-describing format messages. Every message type is defined in the log itself, so no external schema is needed to parse it.
Custom Messages
Any library or vehicle code can define and write its own structured log messages using the
AP::logger().Write() API with a format string that describes field types.EKF Replay
When
LOG_REPLAY = 1, raw sensor data is written alongside filtered outputs. The same log can then be fed back through the EKF offline for post-flight analysis and tuning.MAVLink Log Download
Ground stations can download logs over MAVLink using the log-listing and log-transfer protocol, without removing the SD card from the vehicle.
Log file structure
Each.bin file begins with a series of FMT (format) messages that declare every message type used in that log. Subsequent messages are binary records whose layout is described by the corresponding FMT. This makes the format self-contained.
00000001.BIN, 00000002.BIN, and so on. A new file is started each time the vehicle arms (if LOG_FILE_DISARM_ROT = 1) or on every boot.
Format characters
Theformat string in a log message definition uses single characters to describe each field’s C type. All integers are stored little-endian.
| Char | C type | Notes |
|---|---|---|
f | float | 32-bit IEEE 754 float |
d | double | 64-bit IEEE 754 double |
i | int32_t | Signed 32-bit integer |
I | uint32_t | Unsigned 32-bit integer |
h | int16_t | Signed 16-bit integer |
H | uint16_t | Unsigned 16-bit integer |
b | int8_t | Signed 8-bit integer |
B | uint8_t | Unsigned 8-bit integer |
c | int16_t | Value is multiplied by 100 before storage (centiunits) |
C | uint16_t | Value is multiplied by 100 before storage |
e | int32_t | Value is multiplied by 100 before storage |
E | uint32_t | Value is multiplied by 100 before storage |
L | int32_t | Latitude or longitude (degrees × 10⁷) |
M | uint8_t | Flight mode (vehicle-specific enum) |
n | char[4] | 4-character string (not null-terminated) |
N | char[16] | 16-character string |
Z | char[64] | 64-character string |
q | int64_t | Signed 64-bit integer |
Q | uint64_t | Unsigned 64-bit integer |
a | int16_t[32] | Array of 32 signed 16-bit integers |
The
c, C, e, E types store the value pre-scaled by 100. Log analysis tools automatically apply the inverse scaling, so you write (int16_t)(degrees * 100) but see degrees in the GCS.Defining a custom log message
Log message types are defined using theLogStructure struct. The preferred approach for one-off messages is the AP::logger().Write() variadic API, which does not require a pre-registered struct.
Using AP::logger().Write()
Using a pre-registered struct
For high-rate messages (e.g. IMU-rate logging), register the message type at startup for efficiency:The Write API
AP_Logger exposes three Write variants depending on criticality:
| Method | Behaviour |
|---|---|
Write(name, labels, units, mults, fmt, ...) | Normal (rate-limited if _params.file_ratemax > 0) |
WriteStreaming(name, labels, units, mults, fmt, ...) | Rate-limited streaming; may be dropped under load |
WriteCritical(name, labels, units, mults, fmt, ...) | Never dropped; used for arm/disarm, mode changes, errors |
WriteBlock(pkt, size) | Raw block write using a pre-registered struct |
WriteCriticalBlock(pkt, size) | Critical raw block write |
Common built-in message types
These message types are written automatically by the core ArduPilot libraries:| Name | Source library | Key fields |
|---|---|---|
ATT | AHRS | Roll, pitch, yaw (desired and actual) |
POS | AHRS | Lat, Lng, Alt (EKF estimate) |
GPS | AP_GPS | Fix type, satellites, lat/lng/alt, speed |
BARO | AP_Baro | Altitude, pressure, temperature |
IMU | AP_InertialSensor | AccX/Y/Z, GyrX/Y/Z, temperature |
RCIN | AP_RCInput | RC input channels 1–14 |
RCOU | SRV_Channel | Servo output channels 1–14 |
PARM | AP_Param | Parameter name and value snapshot |
MODE | Vehicle | Flight mode number and reason code |
ERR | AP_Logger | Subsystem error code and error value |
EKF* | AP_NavEKF3 | EKF state, innovations, variances |
BAT | AP_BattMonitor | Voltage, current, remaining capacity |
ARSP | AP_Airspeed | Indicated and true airspeed |
Key parameters
LOG_BITMASK
LOG_BITMASK
Bitmask controlling which subsystems are logged. Each bit enables a group of messages. Set to
-1 (all bits) for full logging, or use Mission Planner’s Full Parameter List to enable individual subsystems. A value of 0 disables all logging.LOG_DISARMED
LOG_DISARMED
Controls logging when the vehicle is disarmed.
| Value | Behaviour |
|---|---|
0 (NONE) | Log only when armed |
1 | Log continuously, including while disarmed |
2 | Log while disarmed but not when connected via USB |
3 | Log while disarmed but discard the log if not armed before shutdown |
LOG_REPLAY
LOG_REPLAY
When set to
1, raw sensor data is additionally logged in a format that the Tools/Replay/ tool can consume. This allows the EKF to be re-run offline with different tuning parameters. Replay logs are significantly larger than standard logs.LOG_FILE_BUFSIZE
LOG_FILE_BUFSIZE
Size of the in-memory write buffer in kilobytes (default 16 KB). Larger buffers reduce SD card write stalls on high-rate logging but consume RAM. Increase this if you see
LOG: out of space messages in fast-loop vehicles.LOG_FILE_RATEMAX
LOG_FILE_RATEMAX
Maximum log rate in Hz (0 = unlimited). Rate-limiting prevents the logger from consuming excessive CPU time during intensive manoeuvres.
LOG_FILE_DISARM_ROT
LOG_FILE_DISARM_ROT
When set to
1, a new log file is started each time the vehicle arms. When 0, a new file is only started on boot.Reading .bin log files
MAVExplorer
MAVExplorer is the recommended command-line tool for graphing and analysing logs:Mission Planner
In Mission Planner, go to DataFlash Logs → Load Log and select a.bin file. Use the Browse Log view to plot any combination of logged fields over time.
pymavlink / Python
EKF Replay
The Replay tool (Tools/Replay/Replay.cpp) reads a log file containing raw sensor data (requires LOG_REPLAY = 1) and re-runs the EKF, writing a new log with the same vehicle trajectory but potentially different EKF outputs.