Skip to content

A Kotlin Parser for Ardupilot/Px4 DataFlash Logs, based on DFReader from the pymavlink project

License

Notifications You must be signed in to change notification settings

HitecCS/KDataflashParser

Repository files navigation

KDataflashParser

A Kotlin library providing a parser and convenience functions for parsing and analyzing Ardupilot/Px4 Dataflash logs. It's compatible with both Binary .bin and Text .log log formats

Overview

If you are totally unfamiliar with the format of DataFlash logs, this project contains a few Wiki pages about them; this article on Ardupilots website is also very helpful.

There is no standard set of messages for DataFlash files as they are self defining. However, if you intend to use this library to parse ArduPlane or ArduCopter logs, you can use these lists of log messages.

ArduPlane: https://ardupilot.org/plane/docs/logmessages.html

ArduCopter: https://ardupilot.org/copter/docs/logmessages.html

Getting Started

To parse a log use the wrapper class DataFlashParser, or you can use the main parsing classes DFReaderBinary or DFReaderText directly

val dfParser = DataFlashParser(filename) { pct : Int -> println("Percent indexed $pct") }

To get a full list of every message in the log you can call getAllMessages. However, this can be quite expensive on the processor and memory. This is especially not recommended on Android as it will quickly hit the memory limit.

 val allDataFlashMessages : ArrayList<DFMessage> = dfParser.getAllMessages()

If you'd like to get all the message of a specific message type you can use: getAllMessagesOfType

val mgsMessages : ArrayList<DFMessage> = dfParser.getAllMessagesOfType("MSG")

If you only need access to certain data fields, you can get lists of every message which contains those fields like this:

val fieldLists : HashMap<String, ArrayList<DFMessage>> = dfParser.getFieldLists(hashSetOf("Roll",
    "Pitch",
    "Yaw",
    "Lat",
    "Lng"))

allDataFlashMessages.size // = 270441
fieldLists["Roll"].size // = 40347

Some fields exist across multiple messages. If you want to filter out messages using some conditional logic with this function: getFieldListConditional

val northernBaroAlts : ArrayList<DFMessage> = dfParser.getFieldListConditional("Alt") { dfMessage -> dfMessage.Mode == "AUTO" }

##License

KDataFlashParser is open source under GNU GPL version 3

This software is based on: APM DataFlash log file reader, Copyright Andrew Tridgell 2011;

APM DataFlash log file reader is partly based on SDLog2Parser by Anton Babushkin

About

A Kotlin Parser for Ardupilot/Px4 DataFlash Logs, based on DFReader from the pymavlink project

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages