Skip to main content

Shared Rust CDR/IDL decoder for ROS and DDS message data (omgidl, ros2idl, ros2msg, ros1msg).

Project description

roboto-mcap-codec

A fast, shared Rust decoder for ROS and DDS message data, packaged as a Python extension. It parses the schema languages used in MCAP and ROS bags — omgidl, ros2idl, ros2msg, ros1msg — and decodes message payloads across every common CDR framing (plain XCDR1/XCDR2, parameter-list PL_CDR, delimited D_CDR2) and the unaligned ROS1 wire, into plain Python dict / list / scalar values.

It powers message decoding in the Roboto Python SDK, where one Rust implementation serves both ingest-time field statistics and query-time message reads.

Install

pip install roboto-mcap-codec

Prebuilt abi3 wheels are published for CPython 3.10+ on Linux (manylinux_2_28, x86-64 and aarch64), macOS (Intel and Apple Silicon), and Windows (x86-64). No Rust toolchain is needed to install.

Quick start

A CdrCodec is built once per channel schema, then reused to decode every message on that channel.

from mcap_codec import CdrCodec

# schema_encoding: "omgidl" | "ros2idl" | "ros2msg" | "ros1msg"
# schema_data:     the raw schema bytes (e.g. an MCAP Schema record's `data`)
# schema_name:     the fully-scoped root type name
codec = CdrCodec("ros2msg", schema_data, "sensor_msgs/msg/Imu")

# payload = the raw message bytes, including the 4-byte CDR encapsulation header
message = codec.decode(payload)        # -> nested dict / list / scalars

Decode only the fields you need (everything else is skipped, not materialized):

partial = codec.decode_fields(
    payload,
    ["angular_velocity.x", "header.stamp.sec"],
)
# -> {"angular_velocity": {"x": ...}, "header": {"stamp": {"sec": ...}}}

Output shape

  • structs → dict; sequences and arrays → list (multi-dimensional arrays → nested lists); octet / uint8 sequences → list[int]
  • scalars → native bool / int / float; strings → str
  • enums → integers
  • unions → {"discriminator": <value>, "<active member>": <value>}
  • Time / Duration{"sec": int, "nanosec": int}
  • absent @optional members are omitted from the dict

Undecodable messages

Some fields have no portable CDR encoding and cannot be decoded reliably. When a message cannot be decoded for such a reason, decode() raises UnsupportedMessage (rather than returning a wrong value). Catch it to skip the message and keep reading the rest of the file:

from mcap_codec import CdrCodec, UnsupportedMessage

try:
    message = codec.decode(payload)
except UnsupportedMessage:
    message = None   # e.g. an implementation-defined `wstring`, or HASH autoid

This matches how the Roboto SDK and the Foxglove decoders treat the same cases.

Errors

  • CdrCodec(...) raises ValueError if the schema cannot be parsed.
  • decode(...) / decode_fields(...) raise ValueError on a genuine decode failure (malformed payload), and UnsupportedMessage for a message that is intentionally declined (see above).

License

Apache-2.0. Part of the Roboto platform.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

roboto_mcap_codec-0.1.3.tar.gz (81.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

roboto_mcap_codec-0.1.3-cp310-abi3-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.10+Windows x86-64

roboto_mcap_codec-0.1.3-cp310-abi3-manylinux_2_28_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

roboto_mcap_codec-0.1.3-cp310-abi3-manylinux_2_28_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

roboto_mcap_codec-0.1.3-cp310-abi3-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

roboto_mcap_codec-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file roboto_mcap_codec-0.1.3.tar.gz.

File metadata

  • Download URL: roboto_mcap_codec-0.1.3.tar.gz
  • Upload date:
  • Size: 81.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for roboto_mcap_codec-0.1.3.tar.gz
Algorithm Hash digest
SHA256 dad27cdd153dbbdb3fd291df221b15605ab35bcdc6d18af92702c37bc709e9f5
MD5 357c600f6b6f222cf8c10e57d9b594f4
BLAKE2b-256 4dcca4ec36acb6758f8a00d82a655be0ad6b45a64fad6523231aa6dee168bf81

See more details on using hashes here.

Provenance

The following attestation bundles were made for roboto_mcap_codec-0.1.3.tar.gz:

Publisher: wheels.yml on roboto-ai/roboto-mcap-codec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file roboto_mcap_codec-0.1.3-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.3-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 de107d443ea13b59ac591ea84daade3c1707e9f2e36a0f7496860120198a946c
MD5 160f1707eef6c5bbb956cf9ae0c947b7
BLAKE2b-256 c21ee4394f1fa8f31288aa9dd873fa83f6df798dff6c00d3ccca9c46a938a89b

See more details on using hashes here.

Provenance

The following attestation bundles were made for roboto_mcap_codec-0.1.3-cp310-abi3-win_amd64.whl:

Publisher: wheels.yml on roboto-ai/roboto-mcap-codec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file roboto_mcap_codec-0.1.3-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.3-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 261b7189d60487bc521105b6e7753dbd6045f0c6ee701b4d219ab6b55b2ab43a
MD5 5e788bca290b82712f3971e1c058ef87
BLAKE2b-256 8002ca5d9b7dca307f37512cd3e458b26b5dc0e69b9eb6e0777242cca61df43f

See more details on using hashes here.

Provenance

The following attestation bundles were made for roboto_mcap_codec-0.1.3-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on roboto-ai/roboto-mcap-codec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file roboto_mcap_codec-0.1.3-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.3-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0582ce79bceed36147bd818d4884bdc3950ede5c876ad65e53a637fd1ce6a3c6
MD5 2460e993cd95e42320b252a02e6629b2
BLAKE2b-256 34a95e50cc70b0042d983e97bbf2706ff0f8df33ff6e2791c723f96103575f5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for roboto_mcap_codec-0.1.3-cp310-abi3-manylinux_2_28_aarch64.whl:

Publisher: wheels.yml on roboto-ai/roboto-mcap-codec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file roboto_mcap_codec-0.1.3-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.3-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b1b27bc38d9d55017fb2296bde31c916d520767ac62da62f47f0bfb520da77a3
MD5 7a726e5ea773f5925ed0088c5b0d0ed6
BLAKE2b-256 6469e4451c19d0f981b16301e134b5592f973d2e8c9908337d0583dcac4c79f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for roboto_mcap_codec-0.1.3-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: wheels.yml on roboto-ai/roboto-mcap-codec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file roboto_mcap_codec-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9ac1b6a243c98e62cf3d88556235426c21e3630e74503a9db513b3935bdda3df
MD5 7ca006ce5c51fa45fd97601ac998680b
BLAKE2b-256 bbc146de543b3d41c46f531ed4d0d1c421654afdf2e1e25e3cd58f373cb613d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for roboto_mcap_codec-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: wheels.yml on roboto-ai/roboto-mcap-codec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page