Skip to main content

ROS2 rosbag data analysis library

Project description

baglab

ROS2 rosbag data analysis library. Load, explore, and visualize rosbag data with MATLAB-like simplicity using pandas DataFrames.

Features

  • Lazy loading — open a bag and read only the topics you need
  • Dot-access — navigate message fields like msg.twist.linear.x
  • Geometry — quaternion/euler conversion, distance, pose interpolation
  • Signal processing — lowpass filter, FFT, differentiation, integration
  • Diagnostics — topic rate, message gaps, latency chain analysis
  • Plotting — time-series, trajectory, step response, error band

Installation

Prerequisites

  • Python 3.10+
  • ROS2 (Humble / Jazzy)

baglab (Python only)

pip install baglab

For development:

git clone https://github.com/Kotakku/baglab.git
cd baglab
pip install -e ".[dev]"

C++ acceleration backend (optional)

Installing baglab_cpp_backend enables near I/O-bound rosbag loading via rosbag2_cpp. Requires a sourced ROS2 environment.

source /opt/ros/humble/setup.bash  # or jazzy

# Option 1: pip install
cd baglab
pip install scikit-build-core pybind11 numpy
pip install --no-build-isolation ./baglab_cpp_backend

# Option 2: colcon build
colcon build --packages-select baglab_cpp_backend
source install/setup.bash

Check whether the backend is available:

import baglab
print(baglab.has_cpp_backend())  # True / False

baglab works without the backend — it falls back to rosbags (pure Python).

Usage

import baglab

# Load a rosbag (lazy loading)
bag = baglab.load("path/to/rosbag")

# List topics
print(bag.topics)
# {"/motor/angle": "sensor_msgs/msg/JointState", ...}

# Access topic data (loaded on first access)
twist_df = bag["/cmd_vel"]

# Dot-access for message fields
twist_df.msg.twist.linear.x         # Series
twist_df.msg.twist.linear.df        # DataFrame (columns: [x, y, z])

# Timestamps
t = baglab.stamp_to_sec(twist_df)                  # absolute [s]
t = baglab.stamp_to_sec(twist_df, relative=True)   # relative (starts at 0)

# Reindex by publication timestamp
twist_df = baglab.reindex_by_stamp(twist_df)

Plot example

import baglab
import matplotlib.pyplot as plt

bag = baglab.load("path/to/rosbag")
twist_df = bag["/cmd_vel"]

t = baglab.stamp_to_sec(twist_df, relative=True)
vel = twist_df.msg.twist.linear.df

fig, axes = plt.subplots(3, 1, sharex=True)
for ax, axis_name in zip(axes, ["x", "y", "z"]):
    ax.plot(t, vel[axis_name])
    ax.set_ylabel(axis_name)
axes[-1].set_xlabel("time [s]")
plt.show()

Documentation

https://kotakku.github.io/baglab/

License

Apache-2.0

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

baglab-0.2.1.tar.gz (45.3 kB view details)

Uploaded Source

Built Distribution

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

baglab-0.2.1-py3-none-any.whl (41.5 kB view details)

Uploaded Python 3

File details

Details for the file baglab-0.2.1.tar.gz.

File metadata

  • Download URL: baglab-0.2.1.tar.gz
  • Upload date:
  • Size: 45.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for baglab-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e8a3b097a847b8b48f51bc973b7aac8d49531086b81dbd947808b7ad80b7e29e
MD5 50810ed37a3c3a1faf5623e4a481b81b
BLAKE2b-256 243013bee3e9a9ebcc71bf59f0492d1420c96bf030471ccdabd83edf03f83c7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for baglab-0.2.1.tar.gz:

Publisher: publish.yml on Kotakku/baglab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file baglab-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: baglab-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 41.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for baglab-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d3e54d8b64b1e72cda8defde99e2f7dd50d917b3923a8cd908d0293d87bd57db
MD5 bab6454c46cf0df1548e758f8e91d8ff
BLAKE2b-256 bc4f3fbb06088456f8c019441eb10b70402bb9390f0afe62d4d6f8e9ca04caeb

See more details on using hashes here.

Provenance

The following attestation bundles were made for baglab-0.2.1-py3-none-any.whl:

Publisher: publish.yml on Kotakku/baglab

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