Log file format (diagnostics part 4)
In parts 1, 2, and 3 I covered some motivation for the updated mjlib diagnostics system and the serialization of individual structures. In this post, I’ll cover how those structures are written into a file from an embedded system like a robot and how diagnostic tools can access them efficiently.
Goals
The top level goals are:
- Efficient to write live from an embedded system: The quad A1 generates log data currently at 400Hz, consisting of hundreds to thousands of telemetry data points in every update. It does this on a relatively low-end raspberry pi 3b+. The format should be able to support writing data at high rates without a significant CPU burden.
- Efficient seeking by time and record: Readers of the file should be able to efficiently seek by time in the stream, as well as extract all of a single record without having to process unnecessary data from the log.
- Self contained: While this property in the log comes from the underlying mjlib serialization format, it is worth re-iterating here. All information necessary to return a JSON or CSV like structure for each instance should be present within the log.
Design
The detailed design of the log format is documented at README.md, here I will give a brief summary.