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

Uploaded CPython 3.10+Windows x86-64

roboto_mcap_codec-0.1.10-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.10-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.10-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.10-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.10.tar.gz.

File metadata

  • Download URL: roboto_mcap_codec-0.1.10.tar.gz
  • Upload date:
  • Size: 111.6 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.10.tar.gz
Algorithm Hash digest
SHA256 f3ff72d952ee71f7c6f2faf26c6458875fd69d68373f76ec8b9cac7294459b73
MD5 aeca0e21c32dc4c3f9a682f4ad44343d
BLAKE2b-256 1cd690e7b98a102aada5d143ec919094c49d1a8a6ca6c61cf00e6331031684d7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.10-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 96b6e2678727d4d0c9083b929d6279fbc6a7b03e37e769f6a6d1e12151d7c583
MD5 bdbadc4222d546393fa03299297750f3
BLAKE2b-256 051c9ad223b7dd21e7c2902ba04faa6e8dff7b59fe307eaa401d0741f1758665

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.10-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 04a5cb94b8d5f2fa5539e2b0cfd291d8752a88ca411c6eedf9ee40a11e4bf763
MD5 2b16b9d962736bcb1cc93642cfa08271
BLAKE2b-256 2f0d7c6aa09447e47a175c458cd9a81a9ca1671f031b7e01509ce1dc57a1b6c8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.10-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f7b231f7095431c0d66b69148f6b6e8fa83ae40a9c29c244214494361ceac594
MD5 d38122b82c7907311beea2c3076b53a3
BLAKE2b-256 4c604468823eb05c60bfe5fa67b7abbf0a1297caca7eb253215d1cfbc9f9fef5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.10-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dde9f38f423eaf024e9bf561568472346a15e894104f8aac010bdbcb9c849f7d
MD5 8436c0d07d2e931ff3ad1da145c0121f
BLAKE2b-256 d29ec2580b195cc8558cddf38872d28391fe28e42b2a51cebfa864eaffe963a2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.10-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 50aa5a88e08f03a5d53cf6377b79e451d7a25a5285a77d28c177b9483c2a183b
MD5 3106e4b6bec74c7bcf336dd160bd8372
BLAKE2b-256 a65e8ea3623fd1d84d4b8fd20f22461f9bfe646dc2f1ae5fe0a3a3c14f7bd91b

See more details on using hashes here.

Provenance

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