Skip to main content

High-performance pure Python ROS2 message serialization and deserialization for MCAP files

Project description

mcap-ros2-support-fast

High-performance pure Python ROS2 message serialization and deserialization for MCAP files.

No dependencies on ROS2 or a ROS2 environment.

Installation

uv add mcap-ros2-support-fast

Usage

Decoding Messages

from small_mcap import read_message_decoded
from mcap_ros2_support_fast.decoder import DecoderFactory

decoder_factory = DecoderFactory()

with open("recording.mcap", "rb") as f:
    for msg in read_message_decoded(f, decoder_factories=[decoder_factory]):
        print(f"{msg.channel.topic}: {msg.decoded_message}")

Encoding Messages

from small_mcap import McapWriter
from mcap_ros2_support_fast import ROS2EncoderFactory

encoder_factory = ROS2EncoderFactory()

with open("output.mcap", "wb") as f:
    writer = McapWriter(f, encoder_factory=encoder_factory)
    writer.start(profile="ros2")

    schema_id = 1
    writer.add_schema(
        schema_id,
        "geometry_msgs/msg/Point",
        "ros2msg",
        b"float64 x\nfloat64 y\nfloat64 z",
    )
    channel_id = 1
    writer.add_channel(channel_id, "/point", "cdr", schema_id)

    point = {"x": 1.0, "y": 2.0, "z": 3.0}
    writer.add_message_encode(channel_id, log_time=0, data=point, publish_time=0)

    writer.finish()

Benchmarks

Median runtime from the non-slow pytest-benchmark suite on the included nuScenes dataset (data/data/nuScenes-v1.0-mini-scene-0061-ros2.mcap, 30,900 messages).

Read Performance

Messages mcap-ros2-support-fast rosbags pybag mcap-ros2
10 5.46 ms 7.47 ms 25.56 ms 365.70 ms
100 36.44 ms 67.04 ms 110.68 ms 1324.51 ms
1000 127.68 ms 234.15 ms - 4210.95 ms

Note: pybag is skipped at 1000 messages because it cannot decode diagnostic_msgs/DiagnosticArray.

Read Summary (median time):

  • 33-67x faster than reference mcap-ros2
  • 1.37-1.84x faster than rosbags
  • 3.04-4.68x faster than pybag (10-100 msgs; pybag skipped at 1000 due to decoder limitations)

Write Performance (Read + Write)

Messages mcap-ros2-support-fast rosbags pybag mcap-ros2
10 17.36 ms 18.33 ms 56.32 ms 928.81 ms
100 119.05 ms 129.59 ms 253.93 ms 3132.39 ms
1000 397.07 ms 460.15 ms - 9193.86 ms

Read+Write Summary (median time):

  • 23.2-53.5x faster than reference mcap-ros2
  • 1.06-1.16x faster than rosbags
  • 2.13-3.24x faster than pybag (10-100 msgs; pybag skipped at 1000 due to decoder limitations)

Write-Only Performance

Messages mcap-ros2-support-fast rosbags pybag mcap-ros2
10 11.34 ms 10.91 ms 30.67 ms 576.93 ms
100 66.75 ms 53.50 ms 104.61 ms 794.56 ms
1000 224.47 ms 177.82 ms - 1357.78 ms

Write-Only Summary (median time):

  • 6.0-50.9x faster than reference mcap-ros2
  • 0.96-1.26x similar to rosbags (rosbags remains slightly faster for write-only)
  • 1.57-2.71x faster than pybag (10-100 msgs; pybag skipped at 1000 due to decoder limitations)

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

mcap_ros2_support_fast-0.3.0.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcap_ros2_support_fast-0.3.0-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file mcap_ros2_support_fast-0.3.0.tar.gz.

File metadata

  • Download URL: mcap_ros2_support_fast-0.3.0.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mcap_ros2_support_fast-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a36eaafe9dc57d28f8c59004d7c652616537ccf480bff5d934109a61dc3b47fd
MD5 65ff40742fdd4e922eed4aeb450450a7
BLAKE2b-256 ae47ebf781bdb7dfe43e348aae837eadd81a42a2745ec3114c5b6718757e3cfa

See more details on using hashes here.

File details

Details for the file mcap_ros2_support_fast-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: mcap_ros2_support_fast-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 22.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mcap_ros2_support_fast-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e4fdfa08546b22350a97bce6bf4584d5a25facb19cbb26575390c16ed27fd39a
MD5 632757bb3cb99761a82e5922e292482e
BLAKE2b-256 813ff895c2e9485b4143102a2ab063628e912c82695131460b2d7e610ac860ed

See more details on using hashes here.

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