The openpilot data pipeline is responsible for capturing high-bandwidth sensor data, segmenting it for reliability, and delivering it to comma's cloud infrastructure. This system ensures that driving data is preserved for model training and debugging while managing limited on-device storage and varying network conditions.
loggerd is the primary C++ daemon responsible for writing cereal messages and encoded video to the device's storage. It organizes data into segments, which are typically 60-second chunks of a drive system/loggerd/loggerd.cc24
Rotation is synchronized across multiple encoders to ensure that logs (rlog), low-resolution video (qcamera.ts), and high-resolution video (fcamera.hevc, ecamera.hevc, dcamera.hevc) all align to the same time boundaries.
LoggerdState tracks this via ready_to_rotate system/loggerd/loggerd.cc32-54loggerd will force a rotation after a timeout or if the segment length exceeds standard limits system/loggerd/loggerd.cc42-50initData, containing device metadata, kernel arguments, and system parameters system/loggerd/logger.cc15-94Sentinel messages indicating the start and end of routes or segments system/loggerd/logger.cc156-162loggerd utilizes JpegEncoder to generate MJPEG thumbnails from camera frames, which are published for the UI and uploaded as part of the drive summary system/loggerd/encoder/jpeg_encoder.cc11-62The following diagram illustrates how loggerd.cc receives encoded data and manages segment transitions.
Diagram: Loggerd Segment Orchestration
Sources: system/loggerd/loggerd.cc24-54 system/loggerd/loggerd.cc115-186 system/loggerd/logger.cc177-197 system/loggerd/encoder/jpeg_encoder.cc52-62 system/loggerd/SConscript1-20
The uploader.py daemon manages the background delivery of logged segments to the comma cloud via Azure Blob Storage.
The uploader selects files based on a priority queue to ensure critical small files are delivered before large video files.
crash/ or boot/ are prioritized.qlog and qcamera have higher priority (lower integer value) than full-resolution .hevc files.zstd on the fly.xattr) user.upload set to b'1'. This signals to deleter.py that the file is safe to remove.Table: Upload Priority and Constraints
| File Type | Priority | Metered Policy | Max Size |
|---|---|---|---|
qlog | 0 | 12h delay | 25 MB |
qcamera.ts | 1 | Only if recently viewed | 5 MB |
*.hevc | 1000 | WiFi Only (default) | No Limit |
deleter.py ensures the device does not run out of storage by deleting old segments.
user.upload xattr set.user.preserve are skipped by the deleter to allow users to save specific drives..lock files created by loggerd.For Over-The-Air (OTA) updates and release distribution, openpilot utilizes a casync inspired system. This provides efficient delta updates by breaking the system image into variable-sized chunks indexed by their SHA-256 hash.
build_stripped.sh script prepares the repository for release by removing submodules, cleaning the environment, and chunking large model files (e.g., .onnx files > 95MB) to stay within GitHub limits tools/release/build_stripped.sh29-48file_chunker.py to facilitate efficient synchronization and storage tools/release/build_stripped.sh48Sources: tools/release/build_stripped.sh29-87
The data pipeline extends to development tools that consume the logs produced by loggerd.
replay tool (C++) allows developers to stream logged data back through the openpilot process stack. It uses LogReader, FrameReader, and SegmentManager to reconstruct the driving environment openpilot/tools/replay/SConscript9-16Diagram: Log Consumption Pipeline
Sources: openpilot/tools/replay/SConscript1-16 openpilot/tools/jotpluggler/SConscript40-115
While uploader.py handles bulk data, athenad.py provides a WebSocket-based JSON-RPC interface for real-time cloud interaction and user-requested uploads.
athenad maintains its own upload_queue for specific files requested via the comma app.UploadItem objects are stored in a PriorityQueue, where a lower priority number indicates higher urgency.Diagram: Athena Upload Pipeline
Refresh this wiki