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

Uploaded CPython 3.10+Windows x86-64

roboto_mcap_codec-0.1.13-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.13-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.13-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.13-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.13.tar.gz.

File metadata

  • Download URL: roboto_mcap_codec-0.1.13.tar.gz
  • Upload date:
  • Size: 114.7 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.13.tar.gz
Algorithm Hash digest
SHA256 06905e003f916154bd1c47f8f6c53eb35bd252ff2f78508a66fbf2a18ba0c84d
MD5 19c9388cb14e2b517eaf4ccd216c6099
BLAKE2b-256 fa9109eb250d7b7e0bbf1d9f58265f0da0b9acd9f68d49af02fba7377c268daa

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.13-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7457a6c16baba271ec95bc0b3e6d8b878adca9c48f7e1ad1c3afbcc31fa6f0ea
MD5 5e7c21943cfd0ffacf1551fe6a33f78b
BLAKE2b-256 8e5ca962f900b89dba7a2f80d49c3471820399b365dfa3f04dfd748ec80865d2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.13-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b119773d3311d65a85a3807988e5cf72a667a69ea50965f24120f29c1fb16424
MD5 a34e10a62c12534a59df32b4e2ae4f56
BLAKE2b-256 95cf2f8357b70e680cbb27f58ea9a4c380f2a03168d3265d8f66328594074bfe

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.13-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c8cdf41829984a8795a050889a5a1d77c54dbe4598d1345cc7d1ad7850f80ba1
MD5 ce6507bddac96cab5cf14ae6a21b815d
BLAKE2b-256 87b78884e700a138f73f8900e6287d1070ad8bc6d2c0ce88a1790f08699ebf9f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.13-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ab7c8c90e9946589adc54f7d761511bd30012fe0ef83f16a313a785e67610fc3
MD5 fb512dddfde904b9be4d41f3a5cbf7da
BLAKE2b-256 1d17c6a7dc914012b9887b29ac09d6ec2502c8ba91a491f0f7810ba94ee97c5e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.13-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0b7455d42d5a1290bb98469b0dc9d54df497cc0d50d4c8a2a179e22d328d1bfd
MD5 f984375ec72928cb7a63c9f72829cbbe
BLAKE2b-256 80d99f2db0d45f42e359771d8af49aab680ddef7ae552245e31c543f4235de9f

See more details on using hashes here.

Provenance

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