---
sidebar:
  label: roboto.formats.mcap
  order: 1
title: roboto.formats.mcap
---
Fetching and decoding of topic data stored in MCAP files.

[`open_for_window()`](/docs/reference/python-sdk/roboto/formats/mcap#roboto.formats.mcap.open_for_window) opens an MCAP file at a URL and downloads in advance only the chunks, MCAP's blocks of stored messages, that hold messages in a time range and, optionally, on one topic. [`McapReader`](/docs/reference/python-sdk/roboto/formats/mcap#roboto.formats.mcap.McapReader) reads messages from that file or any other MCAP stream, decodes messages encoded as JSON, msgpack, ROS 1, or CDR (ROS 2 and OMG IDL schemas), and keeps only the selected fields. Methods such as [`get_data()`](/docs/reference/python-sdk/roboto/domain/topics#roboto.domain.topics.Topic.get_data) and [`get_data()`](/docs/reference/python-sdk/roboto/domain/topics#roboto.domain.topics.MessagePath.get_data) read MCAP files through this package, so most code never calls it.

## Submodules

- [roboto.formats.mcap.accessor](/docs/reference/python-sdk/roboto/formats/mcap/accessor)
- [roboto.formats.mcap.decoded_message](/docs/reference/python-sdk/roboto/formats/mcap/decoded_message)
- [roboto.formats.mcap.fetch](/docs/reference/python-sdk/roboto/formats/mcap/fetch)
- [roboto.formats.mcap.json_decoder_factory](/docs/reference/python-sdk/roboto/formats/mcap/json_decoder_factory)
- [roboto.formats.mcap.msgpack_decoder_factory](/docs/reference/python-sdk/roboto/formats/mcap/msgpack_decoder_factory)
- [roboto.formats.mcap.reader](/docs/reference/python-sdk/roboto/formats/mcap/reader)
- [roboto.formats.mcap.ros_cdr_decoder_factory](/docs/reference/python-sdk/roboto/formats/mcap/ros_cdr_decoder_factory)

## Package Contents

- [Accessor](/docs/reference/python-sdk/roboto/formats/mcap/accessor#roboto.formats.mcap.accessor.Accessor) (data): Function that copies one field's value from a decoded message into an `Accumulator`, and returns `None`.

- [END_OF_STREAM](/docs/reference/python-sdk/roboto/formats/mcap/reader#roboto.formats.mcap.reader.END_OF_STREAM) (data): Value `McapReader.next_decoded` returns in place of a message once the reader has no more messages.

- [McapReader](/docs/reference/python-sdk/roboto/formats/mcap/reader#roboto.formats.mcap.reader.McapReader) (class): Reader that decodes the messages of an MCAP stream and keeps only selected fields.

- [Resolution](/docs/reference/python-sdk/roboto/formats/mcap/accessor#roboto.formats.mcap.accessor.Resolution) (data): Compiled form of one field's path: one that writes nothing, a chain of dictionary keys, or a sequence crossing.

- [build_accessor()](/docs/reference/python-sdk/roboto/formats/mcap/accessor#roboto.formats.mcap.accessor.build_accessor) (function): Build the accessor that reads the path `resolution` describes.

- [compile_accessors()](/docs/reference/python-sdk/roboto/formats/mcap/accessor#roboto.formats.mcap.accessor.compile_accessors) (function): Build one accessor per field, compiled against `sample`, without caching them.

- [getter_for()](/docs/reference/python-sdk/roboto/formats/mcap/accessor#roboto.formats.mcap.accessor.getter_for) (function): Return the attribute reader for `message`.

- [none_resolution()](/docs/reference/python-sdk/roboto/formats/mcap/accessor#roboto.formats.mcap.accessor.none_resolution) (function): Build a resolution whose accessor writes nothing, for a path the message lacks.

- [open_for_window()](/docs/reference/python-sdk/roboto/formats/mcap/fetch#roboto.formats.mcap.fetch.open_for_window) (function): Open an MCAP file at a URL for reading, prefetching only the chunks in a log-time window and on one topic.

- [remap_time_fields()](/docs/reference/python-sdk/roboto/formats/mcap/accessor#roboto.formats.mcap.accessor.remap_time_fields) (function): Return `resolution` with `nsec` renamed to `nanosec` past each ROS 2 time value on its path in `sample`.

- [sequence_resolution()](/docs/reference/python-sdk/roboto/formats/mcap/accessor#roboto.formats.mcap.accessor.sequence_resolution) (function): Build a resolution that crosses the sequence at `pre_path` and applies `sub` to each element.

- [simple_resolution()](/docs/reference/python-sdk/roboto/formats/mcap/accessor#roboto.formats.mcap.accessor.simple_resolution) (function): Build a resolution that reads `path` as a chain of dictionary keys, crossing no sequence.
