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 arrays → bytes (matching mcap_ros2; signed int8 arrays stay list[int], since bytes can't hold negatives). The deprecated byte / char aliases follow their dialect: ROS2 byteuint8 / charint8, ROS1 the reverse
  • 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.9.tar.gz (110.9 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.9-cp310-abi3-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.10+Windows x86-64

roboto_mcap_codec-0.1.9-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.9-cp310-abi3-manylinux_2_28_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

roboto_mcap_codec-0.1.9-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.9-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.9.tar.gz.

File metadata

  • Download URL: roboto_mcap_codec-0.1.9.tar.gz
  • Upload date:
  • Size: 110.9 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.9.tar.gz
Algorithm Hash digest
SHA256 63c8e306065ddc7b84d900a79e28efaadbffe661a9a137b3fc29454d83eec445
MD5 f0a76595bb75b08649ace65a6e52d022
BLAKE2b-256 3daa05e072b8dbd9debb4373911c6ee1ef8db68f29a58856c9eb34887a2d1f9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for roboto_mcap_codec-0.1.9.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.9-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.9-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 185a795303e1034bdf13d1e0408210a0063264b3dc1cc090a0f25919c9162347
MD5 582875bb42fafe22316f52bda132c1aa
BLAKE2b-256 1b4a845671b5aabe53578c22f048de1d24e776790c83ed166197fb7f688fd6d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for roboto_mcap_codec-0.1.9-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.9-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.9-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c3af2e4920f63aa90e2412c53efe8d22814e07da91dcaff9b29f2142bcb72705
MD5 48186c4667062fb148e7475eb9cd912e
BLAKE2b-256 deaf8629952b859b028ff934aa1c66528c2a6c6efb49debd3527163e685e2208

See more details on using hashes here.

Provenance

The following attestation bundles were made for roboto_mcap_codec-0.1.9-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.9-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.9-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8c202b82f08fd6516a75b3105a1ffb0728aa1b3f2fae094326885442d227085e
MD5 18818639f18b5de0d261e6855e3789a4
BLAKE2b-256 80b85ae10fa7ed4b0ba683b724801a4ca9e0d063915a17240e05544c3816a87d

See more details on using hashes here.

Provenance

The following attestation bundles were made for roboto_mcap_codec-0.1.9-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.9-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.9-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d2e42e454af8c0974c50d15f673733511ce379bfcbe71a1aa91da388b3a202df
MD5 59a07c3f91ca4ad8437c54080a8b003a
BLAKE2b-256 677bb2d477895f394fd99e43f8c19dd32ed1a62603b690486fd858fd5c26c215

See more details on using hashes here.

Provenance

The following attestation bundles were made for roboto_mcap_codec-0.1.9-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.9-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.9-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8f00d724bd740e57b66309e6cf082f6eaf0af55e5d3f1ac62f7433d23242a579
MD5 912e87eebd7e059b35a48db0776d2bfd
BLAKE2b-256 ed568b3f8a3067c1496c0027ea97cd787f726638d911b5886c5b0a45e84dc89f

See more details on using hashes here.

Provenance

The following attestation bundles were made for roboto_mcap_codec-0.1.9-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