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.4.tar.gz (84.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.4-cp310-abi3-win_amd64.whl (1.0 MB view details)

Uploaded CPython 3.10+Windows x86-64

roboto_mcap_codec-0.1.4-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.4-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.4-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.4-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.4.tar.gz.

File metadata

  • Download URL: roboto_mcap_codec-0.1.4.tar.gz
  • Upload date:
  • Size: 84.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.4.tar.gz
Algorithm Hash digest
SHA256 3306a368388ed0a8948c6025ae1d7eeb1d4d757aff500d738da86c08325dfa85
MD5 2d7572001b6910f97f9d66e09adf8afa
BLAKE2b-256 b54450d7eaf78c34018ea3852f5fada1ed1be1c6a2c373858e2ab61f03c721e3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.4-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3fe7120f3918b041f2f303c30849942730d5cbf059a47a2d57e863686d4a7ae4
MD5 1bc7e26f42e43d5244b9b783ea3dc09e
BLAKE2b-256 871d893cdd34efa5292a3f427a988f3debe19bd569a835ec2fc47a9fa0d9b962

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.4-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4561251094d4c97eed9a657f2de8c859637473d8a14009a2798a071e6fa39178
MD5 0b5d21ec42f7e7dc193fc116205099a8
BLAKE2b-256 fd7b30b012a5224ffc249bb2c6e7921221bf37487a038c86713e4861df7a2961

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.4-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 769a450dcccad2aedd9c6b1824300f53f3f0d9531fee053ec55175094e6ce69e
MD5 c7247249fc9a417e474e81f620c1f598
BLAKE2b-256 19c5dbccd950fcb735158dda3d9405e92e0c1214ca4ade33481ea92a7a2f4982

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.4-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 07d777673e48fbfdf7f21497a4e09088bbb048535610cfa45457003c7359983c
MD5 932e164641d1014bdb931be701b3aae6
BLAKE2b-256 14b6f0b47d0c5cd0c3468a733ff2cf131dce987bc908630a750dbc316149f257

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.4-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d1deda133ef2923723b758bbe97824110f2a867960306e16a5ed7e6a4766ebe7
MD5 9e7d6d10dfb06643c944c1173e47a82b
BLAKE2b-256 e4038479c0a27479926986747b5f0741802e426fba3463fc7c4082c3d3afa4fe

See more details on using hashes here.

Provenance

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