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

Uploaded CPython 3.10+Windows x86-64

roboto_mcap_codec-0.1.2-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.2-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.2-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.2-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.2.tar.gz.

File metadata

  • Download URL: roboto_mcap_codec-0.1.2.tar.gz
  • Upload date:
  • Size: 80.4 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.2.tar.gz
Algorithm Hash digest
SHA256 9105dcee6e2d01cfa5f426bdabcf1fe9cce8409ab703d704082181767babf401
MD5 1c3374d36f5f7e67e4d9243993f1f009
BLAKE2b-256 103ece4bd9c87c6566612c43001c002a40aa9ab773142a101e5f43e7249d588d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b8eda697d00b80a876f1ba571f818c2820cd1892fe3c40d0ea833736b8b3858d
MD5 086ac79a560a311d2245d3e362dac059
BLAKE2b-256 e21bb59553500ad8a37941576f96e0f26181242ac8a47693672a44696867e63e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.2-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f0c5c546ab3f3824b77e6a85a09ddda501204af2bfa7c3a19f88814b94671e10
MD5 b8fd040bdb319d95ffae493def630371
BLAKE2b-256 5b747421faf9a1f470dbf434db6f3b7893c24109310ebb59f5ab4f95b484409b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.2-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 af70e947af0550e010f1ff143fd57b25b9ad897cfb4ff043f5d9675cdf918c47
MD5 12948f0bb85708c61bb94dc0c15f2a14
BLAKE2b-256 38a44af868e3f0248a5ebc485fbbcf0a5471816e9439b3ef719a0e1118d00b56

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 71e9a2237299c36730a4ee5f7f565887d7c77d5c38b26ba9a904ac424954bf77
MD5 d46b271a4aa607bb689fe1593d3f607d
BLAKE2b-256 26156d684f7cd9469f3ec80c8b21aca49e7dfd077f4c90f26c48e4306452040b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.2-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d8e1f71314398f4cb6017300bd86132d2bfa08861caa6287a87e7d781afc5390
MD5 52b494b5dd46255fe4fa6a99dfa78ae6
BLAKE2b-256 9dd978b5884aa33c7f77681e9117900b1dd6b98414996c68eec4b3ae97c20671

See more details on using hashes here.

Provenance

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