{"library":"mcap-ros2-support","title":"MCAP ROS2 Support","description":"mcap-ros2-support provides utilities to seamlessly integrate ROS2 messages with the MCAP data logging format. It allows for efficient recording and playback of ROS2 data within MCAP files, handling schema definition and message serialization/deserialization. The current version is 0.5.7, and the project (including core mcap, CLI, and other support libraries) has a frequent release cadence.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install mcap-ros2-support"],"cli":null},"imports":["from mcap_ros2.writer import Ros2RawWriter","from mcap_ros2.reader import Ros2Reader","from mcap.mcap_writer import McapWriter"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom pathlib import Path\nfrom mcap.mcap_writer import McapWriter\nfrom mcap_ros2.writer import Ros2RawWriter\nfrom mcap_ros2.reader import Ros2Reader\n\n# Assuming a ROS2 message type is available, e.g., from an installed ROS2 package\n# For demonstration, we'll mock a simple message structure for 'std_msgs/msg/String'\n# In a real scenario, you would import the actual message type and populate it.\nclass MockStringMsg:\n    _TYPE = 'std_msgs/msg/String'\n    _HAS_HEADER = False\n    _LAYOUT = [\n        ('data', 'string'),\n    ]\n    _REGISTERED_TYPES = {}\n    _CDR_TYPES = {}\n\n    def __init__(self, data=''):\n        self.data = data\n\n    def __repr__(self):\n        return f\"MockStringMsg(data='{self.data}')\"\n\n    @staticmethod\n    def get_fields_and_field_types():\n        return [('data', 'string')]\n\n    def get_type_description_interfaces(self):\n        # Simplified mock for the purpose of the quickstart\n        return {'type_description': 'string data'}\n\n# Write a simple MCAP file with a ROS2 message\noutput_file = Path('ros2_messages.mcap')\nwith open(output_file, 'wb') as f,\n     McapWriter(f) as mcap_writer,\n     Ros2RawWriter(mcap_writer) as ros2_writer:\n\n    # In a real ROS2 environment, you'd create actual ROS2 messages\n    # from std_msgs.msg import String\n    # msg = String(data='Hello ROS2 from MCAP!')\n    mock_msg = MockStringMsg(data='Hello ROS2 from MCAP!')\n    topic = '/chatter'\n    log_time_ns = 123456789\n\n    # The Ros2RawWriter can infer the schema from a ROS2 message object.\n    # For this mock, we ensure the mock_msg has the necessary _TYPE and field info.\n    ros2_writer.write_message(\n        topic=topic,\n        message=mock_msg,\n        log_time_ns=log_time_ns,\n        publish_time_ns=log_time_ns\n    )\n\nprint(f\"Wrote ROS2 message to {output_file}\")\n\n# Read the MCAP file and verify\nwith open(output_file, 'rb') as f:\n    reader = Ros2Reader(f)\n    for msg, schema, channel in reader.iter_decoded_messages():\n        print(f\"Read message from topic '{channel.topic}': {msg}\")\n        assert msg.data == 'Hello ROS2 from MCAP!'\n        break # Only read one message for this example\n\n# Clean up the created file\nos.remove(output_file)\nprint(f\"Cleaned up {output_file}\")\n","lang":"python","description":"This quickstart demonstrates how to write and read a ROS2 message to and from an MCAP file using `mcap-ros2-support`. It mocks a `std_msgs/msg/String` for demonstration, but in a live ROS2 environment, you would import actual message types. It uses `Ros2RawWriter` to encode ROS2 messages into the MCAP format and `Ros2Reader` to decode them back. The core `McapWriter` is used for the underlying MCAP file operations.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"0.5.7","pypi_latest":"0.5.7","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":50,"avg_install_s":2.1,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"mcap-ros2-support","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"mcap-ros2-support","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.2,"import_time_s":null,"mem_mb":null,"disk_size":"47M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"mcap-ros2-support","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"mcap-ros2-support","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2,"import_time_s":null,"mem_mb":null,"disk_size":"49M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"mcap-ros2-support","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"mcap-ros2-support","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.8,"import_time_s":null,"mem_mb":null,"disk_size":"41M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"mcap-ros2-support","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"mcap-ros2-support","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.9,"import_time_s":null,"mem_mb":null,"disk_size":"41M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"mcap-ros2-support","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"mcap-ros2-support","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.4,"import_time_s":null,"mem_mb":null,"disk_size":"47M"}]}}