Protocol Buffers (protobuf)

Protocol Buffers, or protobuf, is a language-neutral format for serializing structured data, developed by Google and open sourced in 2008. You define message types in a .proto schema, a compiler generates code for each language, and messages travel as compact binary. In robotics, protobuf is one of the message encodings that MCAP files support, alongside the CDR encoding used by ROS 2, JSON, and FlatBuffers.

What are Protocol Buffers?

Protocol Buffers are a way to turn structured data into bytes and back. Engineers describe each message in a .proto file, listing fields with a name, a type, and a number. The protoc compiler turns that file into classes for languages such as C++, Python, Java, and Go, and those classes serialize and parse messages. The result is smaller and faster to parse than the same data written as JSON.
Each field number is permanent. New code can add fields that old code safely ignores, and when a field is deleted, its number should be marked reserved so nothing reuses it. That is what lets a message format evolve while older readers keep working.

Key takeaways

  • Protobuf serializes structured data into compact binary using a schema written in a .proto file.
  • Protobuf messages are not self-describing, so a reader needs the schema to decode them.
  • MCAP solves that by storing the protobuf schema inside the recording, next to the messages.

Open an MCAP recording without installing the robot's software

A recording is only useful if every channel decodes. When you load robot logs, check for:
  • channels that decode to empty or constant values
  • streams whose rates drift from what the robot should publish
  • schemas that changed between recordings in the same dataset
In Voxel51, the CAVERS dataset holds multimodal SLAM recordings as MCAP, with RGB-D, LiDAR, thermal, and IMU streams on one timeline.

CAVERS Trajectories

3 recordings

Multimodal SLAM recordings from a natural karstic cave as MCAP, with RGB-D, LiDAR, thermal, and IMU streams and motion-capture ground truth.

Try this: Open one recording and play every stream on the shared timeline. Then look for a stream that drops out while the others keep going.

Explore CAVERS in Voxel51

Free with a work or .edu email.

Go deeper

How it works in robot logs

Robots publish streams of messages, such as camera frames, poses, and joint states, and a log has to keep both the bytes and the schema that explains them. In an MCAP file, each channel declares its message encoding and points to a schema record. For protobuf, that schema is a binary FileDescriptorSet generated by protoc with all imports included, and the schema name is the message's fully qualified name, such as foo.bar.Baz. Because the schema travels with the data, any tool that understands MCAP can decode a protobuf channel without the original robot's code.
MCAP stores the protobuf schema with the messages, so any reader can decode them.
ROS 2 serializes its messages with CDR by default, so a recording from a ROS 2 robot usually has CDR channels, while logging stacks built outside ROS often use protobuf. One MCAP file can mix both. Protobuf assumes a whole message fits in memory and is not designed for large arrays of numbers, so dense data such as images and point clouds is usually stored as raw or compressed bytes inside a protobuf field.

Why it matters

Schemas are where robot data quietly breaks. A missing schema makes a channel unreadable, and a schema that does not match the code that wrote the messages can decode into wrong values without an error. Protobuf's field numbering keeps old logs readable as message types evolve, but only if the schema stored in the log is the one that wrote it. Checking channels and schemas is part of auditing any recording before it becomes physical AI training data, and What Actually Breaks When You Author MCAP by Hand walks through the failures that show up most.
Protobuf messages need their schema to decode.

Frequently asked questions

Is protobuf better than JSON?

For data passed between machines, usually. Protobuf messages are smaller and faster to parse, and the schema enforces types. JSON is easier for people to read and needs no schema, which is why it stays common for configuration and debugging.

Does ROS 2 use protobuf?

Not by default. ROS 2 serializes messages with CDR through its DDS middleware. Protobuf shows up in robot stacks built outside ROS and in tools that log or bridge data between systems.

How does MCAP store protobuf data?

Each protobuf channel in an MCAP file points to a schema record that holds a FileDescriptorSet, so a reader can decode the messages without the original .proto files.
black and white photo of Jesse Mostipak
Director of Growth
Jesse Mostipak is the Director of Growth at Voxel51, where the work is helping humans find and trust what the brand knows, and teaching the Google knowledge graph and the LLMs answering on their behalf to do the same. That question, how knowledge gets built inside a system, is one Jesse has been chasing for years. Earlier versions of it ran through a New York City high school science classroom, data science and machine learning, and developer relations at Kaggle, Posit (formerly RStudio), and Baseten. The answer doesn't change much depending on whether the learner is a teenager, a software engineer, or a knowledge graph. Jesse holds a Master's in Education from CUNY Hunter College. LinkedIn
See all articles by Jesse Mostipak
Last updated November 19, 2026

Building visual or physical AI?

Let's talk.