Skip to main content

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

Project description

pipeline status coverage report python versions PyPI - Downloads

Rosbags

Rosbags is the pure python library for everything rosbag. It contains:

  • highlevel easy-to-use interfaces,

  • rosbag2 reader and writer,

  • rosbag1 reader and writer,

  • extensible type system with serializers and deserializers,

  • efficient converter between rosbag1 and rosbag2,

  • and more.

Rosbags does not have any dependencies on the ROS software stacks and can be used on its own or alongside ROS1 or ROS2.

Rosbags was developed for MARV, which requires a fast, correct, and flexible library to read, manipulate, and write the various rosbag file formats.

Getting started

Rosbags is published on PyPI and does not have any special dependencies. Simply install with pip:

pip install rosbags

Read and deserialize messages from rosbag1 or rosbag2 files:

from pathlib import Path

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

bagpath = Path('/home/ros/rosbag_2020_03_24')

# Create a type store to use if the bag has no message definitions.
typestore = get_typestore(Stores.ROS2_FOXY)

# Create reader instance and open for reading.
with AnyReader([bagpath], default_typestore=typestore) as reader:
    connections = [x for x in reader.connections if x.topic == '/imu_raw/Imu']
    for connection, timestamp, rawdata in reader.messages(connections=connections):
         msg = reader.deserialize(rawdata, connection.msgtype)
         print(msg.header.frame_id)

Convert between rosbag versions:

# Convert "foo.bag", result will be "foo/"
rosbags-convert foo.bag

# Convert "bar", result will be "bar.bag"
rosbags-convert bar

# Convert "foo.bag", save the result as "bar"
rosbags-convert foo.bag --dst /path/to/bar

# Convert "bar", save the result as "foo.bag"
rosbags-convert bar --dst /path/to/foo.bag

Documentation

Read the documentation for further information.

Contributing

Thank you for considering to contribute to rosbags.

To submit issues or create merge requests please follow the instructions provided in the contribution guide.

By contributing to rosbags you accept and agree to the terms and conditions laid out in there.

Development

Clone the repository and setup your local checkout:

git clone https://gitlab.com/ternaris/rosbags.git

cd rosbags
python -m venv venv
. venv/bin/activate

pip install -r requirements-dev.txt
pip install -e .

This creates a new virtual environment with the necessary python dependencies and installs rosbags in editable mode. The rosbags code base uses pytest as its test runner, run the test suite by simply invoking:

pytest

To build the documentation from its source run sphinx-build:

sphinx-build -a docs public

The entry point to the local documentation build should be available under public/index.html.

Support

Professional support is available from Ternaris.

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

sixriver_rosbags-0.0.2.tar.gz (191.2 kB view details)

Uploaded Source

Built Distribution

sixriver_rosbags-0.0.2-py3-none-any.whl (131.3 kB view details)

Uploaded Python 3

File details

Details for the file sixriver_rosbags-0.0.2.tar.gz.

File metadata

  • Download URL: sixriver_rosbags-0.0.2.tar.gz
  • Upload date:
  • Size: 191.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for sixriver_rosbags-0.0.2.tar.gz
Algorithm Hash digest
SHA256 bdeb1b31ebc8c1c6644fb0d3e121b03e56fcd36006dafef0639909ca497a8826
MD5 f5c4d0f8e202fe6b2358ed3d904f22ba
BLAKE2b-256 940248df504cfbdaea0865e6768f7f8450fa56b4d17e654fb91fd630b657b549

See more details on using hashes here.

File details

Details for the file sixriver_rosbags-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for sixriver_rosbags-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 47a17e6872e3dbe9a7286d1af641ae862ca87eedce159a066fecc72ee37228bc
MD5 8896ea5fd32bec2dd2d9a6bcfc3ead62
BLAKE2b-256 170ac9dc2a9c5748b2ad82840e055e1b83302469257290dd3fa74d2f8e1f1ed1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page