Working with MCAP

The Rerun Viewer has built-in support for opening MCAP files, an open container format for storing timestamped messages.

Supported message formats

Here's a quick summary of Rerun's MCAP importer:

  • Automatic conversion to Rerun archetypes is supported for common ROS 2 & Foxglove messages.
  • Other ROS 2 & Foxglove messages are decoded into queryable components via reflection.

For a detailed overview of Rerun's built-in MCAP support, please refer to our Supported Message Formats page. To request support for a new message type, see Adding support for new types.

Quick start

Loading MCAP files

The simplest way to get started is to load an MCAP file directly:

# View an MCAP file in the Rerun Viewer
rerun your_data.mcap

You can also drag and drop MCAP files into the Rerun Viewer or load them using the SDK:

"""Load an MCAP file using the Python SDK."""

import sys

import rerun as rr

path_to_mcap = sys.argv[1]

# Initialize the SDK and give our recording a unique name
rr.init("rerun_example_load_mcap", spawn=True)

# Load the MCAP file
rr.log_file_from_path(path_to_mcap)
recording = rr.get_data_recording()
assert recording is not None
recording.flush()

Python McapReader

For custom ingestion or processing pipelines, use the Python McapReader to read an MCAP file into a LazyChunkStream that can be used to build custom data wrangling pipelines. For example, you can inspect file metadata with reader.info(), select decoders, filter topics or time ranges, transform chunks using Lenses, and write the result to RRD:

from rerun.chunk import McapReader

reader = McapReader(mcap_path)
print(reader.info().message_count)

# Stream chunks, optionally filter or transform them, and write to RRD.
reader.stream().write_rrd(
    output_path,
    application_id="rerun_example_process_mcap",
    recording_id="example",
)

See the Chunk Processing API for examples of filtering and transforming MCAP chunks. For a comprehensive example covering a full robotics pre-processing pipeline, see the robot_data_preprocessing example.

Basic conversion

Convert MCAP files to Rerun's native format for faster loading:

# Convert MCAP to RRD format for faster loading
rerun mcap convert input.mcap -o output.rrd

# View the converted file
rerun output.rrd

ROS bags that are not MCAP

Rerun only reads ROS bags stored as MCAP.

  • ROS 2 .db3 (SQLite) bags are not supported. Convert them to MCAP with ros2 bag convert (part of rosbag2, not Rerun), which takes an output-options YAML file:

    # convert.yaml
    output_bags:
      - uri: my_bag_mcap
        storage_id: mcap
        all_topics: true # Use `all: true` on ROS 2 Humble.

    Without a topic selection, the output bag is empty. See the rosbag2 docs for all options.

    ros2 bag convert -i my_bag -o convert.yaml

    This needs the MCAP storage plugin for rosbag2 (ros-$ROS_DISTRO-rosbag2-storage-mcap). Newer ROS 2 distributions record to MCAP by default.

  • ROS 1 .bag files are not supported. Convert them to a ROS 2 MCAP with rosbags-convert, see ROS 1 message types.

Recording ROS 2 bags as RRD

If you use rosbag2, you can record straight to RRD with rosbag2_storage_rrd, an experimental rosbag2 storage plugin:

ros2 bag record -s rrd --all

ros2 bag play replays the bag, and Rerun opens and queries it like any other .rrd. It can also stream to a running Viewer while recording. See the plugin's README for its current status and build instructions.

Data model

Rerun's data model is based on an entity component system (ECS) that is a bit different to the message-based model of MCAP. To map MCAP messages to Rerun entities we make the following assumptions:

  • MCAP topics correspond to Rerun entities.
  • Messages from the same topic within an MCAP chunk will be placed into a corresponding Rerun chunk.
  • The contents of an MCAP message will be extracted to Rerun components and grouped under a corresponding Rerun archetype.
  • message_log_time and message_publish_time of an MCAP message will be carried over to Rerun as two distinct timelines.

For how other ROS concepts, such as latched topics and TF, map onto Rerun, see Comparison with ROS.

Decoder architecture

Rerun uses decoders to process MCAP files at different levels of abstraction, from keeping only the raw message bytes up to a full semantic conversion to Rerun archetypes. See MCAP decoders explained for what each decoder does and which ones run by default, and Decoder selection for how to select them.

Command-line examples

These are the common command-line workflows for MCAP files. For every option, see the rerun mcap reference.

Basic commands

Direct viewing

Open MCAP files directly in the Rerun Viewer:

# View a single MCAP file
rerun data.mcap

# View multiple specific files
rerun file1.mcap file2.mcap file3.mcap

# Use glob patterns to load all MCAP files in a directory
rerun recordings/*.mcap

# Recursively load all MCAP files from a directory
rerun mcap_data/

File conversion

Convert MCAP files to Rerun's native RRD format:

# Convert MCAP to RRD format for faster loading
rerun mcap convert input.mcap -o output.rrd

# Convert with custom output location
rerun mcap convert data.mcap -o /path/to/output.rrd

Decoder selection

Using specific decoders

Control which processing decoders are applied during conversion:

# Use only protobuf decoding and file statistics
rerun mcap convert input.mcap -d protobuf -d stats -o output.rrd

# Use only ROS2 semantic interpretation for robotics data
rerun mcap convert input.mcap -d ros2msg -o output.rrd

# Add robot geometry from ROS robot_description topics
rerun mcap convert input.mcap -d ros2msg -d urdf -o output.rrd

# Combine multiple decoders for comprehensive data access
rerun mcap convert input.mcap -d ros2msg -d raw -d recording_info -o output.rrd

For what each decoder does and which ones run by default, see MCAP decoders explained. For every option of rerun mcap convert, see the CLI reference.