Reading MCAP Files#
MCAP is an open-source container file format for multimodal log data, commonly used in robotics and autonomous systems. Daft can read MCAP files using [daft.read_mcap()][daft.io.read_mcap].
Basic Usage#
1 2 3 4 | |
1 2 3 4 5 6 | |
1 2 3 4 | |
1 2 3 4 5 | |
Output Schema#
The read_mcap function returns a DataFrame with the following schema:
| Column | Type | Description |
|---|---|---|
source_path | string | Path of the MCAP file containing the message |
topic | string | The topic name the message was published on |
log_time | uint64 | Timestamp when the message was logged (nanoseconds) |
publish_time | uint64 | Timestamp when the message was published (nanoseconds) |
sequence | uint32 | Sequence number of the message |
data | binary | Raw message payload |
If use_legacy_types=True, the DataFrame schema will match the legacy implementation.
| Column | Type | Description |
|---|---|---|
source_path | string | Path of the MCAP file containing the message |
topic | string | The topic name the message was published on |
log_time | int64 | Timestamp when the message was logged (nanoseconds) |
publish_time | int64 | Timestamp when the message was published (nanoseconds) |
sequence | int32 | Sequence number of the message |
data | string | Message payload |
Deprecated use_legacy_types=True flag
use_legacy_types=True is deprecated and will be removed in v0.9.0. Update your script to use the currently emitted column types.
Filtering Options#
Time Range#
Filter messages by time range. The time unit matches the MCAP log_time field (typically nanoseconds):
1 2 3 4 5 6 | |
Unsigned timestamp bounds
Ensure that start_time, end_time, and times returned by topic_start_time_resolver must be between 0 and 2**64 - 1 to match the internal MCAP timestamp format. Negative time values raise OverflowError.
Topic Filtering#
Read only specific topics:
1 2 3 4 5 | |
Batch Size#
Control memory usage by adjusting the batch size:
1 2 3 4 | |
Advanced: Topic Start Time Resolver#
For advanced use cases, you can provide a callable that computes per-file, per-topic start times. This is useful for resuming reads from specific positions:
1 2 3 4 5 6 7 8 9 10 11 12 | |
When a resolver is provided: - One scan task is created per (file, topic) combination - The task's start_time is set to max(start_time, resolver(file)[topic])
Use Cases#
Robotics Data Processing#
1 2 3 4 5 6 7 8 9 | |
Multi-Topic Analysis#
1 2 3 4 5 6 7 8 9 10 11 12 | |