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.12.tar.gz (110.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.12-cp310-abi3-win_amd64.whl (966.5 kB view details)

Uploaded CPython 3.10+Windows x86-64

roboto_mcap_codec-0.1.12-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.12-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.12-cp310-abi3-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

roboto_mcap_codec-0.1.12-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.12.tar.gz.

File metadata

  • Download URL: roboto_mcap_codec-0.1.12.tar.gz
  • Upload date:
  • Size: 110.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.12.tar.gz
Algorithm Hash digest
SHA256 010404a6d84a8d9b445c0d73033923714c815cabaa2a66593df4655567cdf38c
MD5 794cd68788e86056a1981dbd374af196
BLAKE2b-256 4355c2bba86b95e2764a21944491953c1d356a143132dddb5f443985849aa19b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.12-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ddc8deebcebe91b5b83b1aa79738995990d444eb9f8b970297029eaa47700a6d
MD5 fd49ea4e6ed5f7d4785ccb337a300fc8
BLAKE2b-256 6e713a475a0da30cca86ca88a9f60ded560ec1c4d3be616db0fcb13b4e58916b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.12-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8d767036370adce60c263b9f9800580570838c89d2cf3d1ed47031e36444a710
MD5 37433cf382e0d143fb5998ff462f1c62
BLAKE2b-256 d49b1dd2bf20e74a12e251adfdeb0c78e3079f62b3669727f16cc95efce754e2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.12-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bce6929ce897e327f1f126584663222433d5c7b5bacee153a029e2a8491042f9
MD5 9dbc2385e19816e1bb4b22326f085941
BLAKE2b-256 b7b0684016bc97e4e00b719c96bf3efe14d21bc4f8c8951ca886a348d9dc5819

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.12-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3d27e6e6c0bc9beb79a3de3ee9b5989afe0ab92cd0d10451f876bd3445eab951
MD5 85932339bf2f00ea8820bf602d6a084c
BLAKE2b-256 0d0f57e6e6932180da96d6305332d3b77d3feed0fd0eec521034a9c43bbd12eb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for roboto_mcap_codec-0.1.12-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9ad07143d671900cf02b5eaebba135c6a6d7f43972be74e9ad8f8c3a08b22138
MD5 b93ec90f2ede17a1cb2d9a0ce1000094
BLAKE2b-256 a2cd55d850b454f2a143c45c3c38e7a1149acf2f804f9f3379702d7974e9bfad

See more details on using hashes here.

Provenance

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