skillfed

rosbags

Pure Python library to read, modify, convert, and write rosbag files.

rosbags v0.11.4 732.6K downloads/30d#5,201 on PyPI
Permissive license Apache-2.0 Active released

What it is and what it does

Rosbags is a pure Python library for reading, writing, and converting ROS bag files without requiring ROS to be installed. It supports both rosbag1 (the original format) and rosbag2 (the newer format), and includes an extensible type system for serializing and deserializing message data. The library was developed for MARV robotics and can be used standalone or alongside ROS1 or ROS2 installations.

The package provides high-level interfaces for common tasks like reading messages from a bag file and deserializing them into Python objects, as well as command-line tools for converting between rosbag formats. Its dependencies are minimal and well-established (numpy, lz4, zstandard for compression, ruamel.yaml for configuration, and apsw for database access), making it straightforward to integrate into robotics data pipelines or analysis workflows.

Use it for:

  • Extract and analyze sensor data (IMU, camera, lidar) from rosbag files in a Python script without installing ROS.
  • Convert rosbag1 files to rosbag2 format or vice versa using the rosbags-convert command-line tool.
  • Build data processing pipelines that read rosbag messages, deserialize them, and feed them into machine learning or analysis frameworks.
  • Inspect and validate rosbag file contents programmatically to verify message types and topics before processing.
  • Integrate rosbag reading into CI/CD workflows or cloud-based systems where a full ROS installation is impractical.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Read, write, convert, and deserialize ROS bag files (rosbag1 and rosbag2 formats) without requiring ROS itself to be installed.

Yes. Rosbags is actively maintained, has no known vulnerabilities, supports current Python versions (3.10–3.14), and solves a real problem for robotics engineers who need to work with bag files outside a ROS environment. The pure Python implementation and low dependency footprint make it easy to integrate. Install it if you work with ROS data and need portable, lightweight bag file access.

Install

rosbags on PyPI

pip

pip install rosbags

uv

uv add rosbags

poetry

poetry add rosbags

Installing rosbags

Before you install

Low friction: pure Python wheel with six runtime dependencies (apsw, lz4, numpy, ruamel.yaml, typing_extensions, zstandard). Actively maintained with a release 2 days ago.

License in practice

Apache-2.0 permissive license allows use in commercial and private projects with minimal restrictions.

Quickstart

pip install rosbags

from rosbags.highlevel import AnyReader
from rosbags.typesys import Stores, get_typestore
from pathlib import Path

typestore = get_typestore(Stores.ROS2_FOXY)
with AnyReader([Path('bagfile')], default_typestore=typestore) as reader:
    for connection, timestamp, rawdata in reader.messages():
        msg = reader.deserialize(rawdata, connection.msgtype)

Requires Python 3.10 or later.

Verify before relying

  • Performance characteristics when handling large rosbag files or many messages in sequence.
  • Whether the type store covers all ROS distributions or only a subset of common ones.

Package facts

License Apache-2.0 (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 6 — apsw, lz4, numpy, ruamel.yaml, typing_extensions, zstandard
Maintenance actively maintained — 2 days since the last release
First released
Downloads 732,647/month — #5,201 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: rosbags-0.11.4-py3-none-any.whl

Keywords: cdr, conversion, deserialization, idl, mcap, message, msg, reader, ros, ros2, rosbag, rosbag2, serialization, writer

Development Status :: 4 - BetaProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Scientific/EngineeringTyping :: Typed

Tags

rosbag reader writer pythonros bag file conversionrosbag1 rosbag2 deserializerobot operating system data extractionmcap cdr serialization ros
roboticsdata-serializationfile-format

More Scientific/Engineering packages