Skip to content

Repository files navigation

blobjugglerpy

Export ROS2 rosbag2 to CSV in PlotJuggler style or per-topic.

Usage

Python API:

from blobjugglerpy import collect_columns_plotjuggler, write_plotjuggler_csv

columns, storage_id, type_cache = collect_columns_plotjuggler(bag_dir, topics_filter=None)
write_plotjuggler_csv(bag_dir, out_csv_path, columns, storage_id, topics_filter=None, type_cache=type_cache)

CLI, single bag:

python -m blobjugglerpy --bag /path/to/bag --out /path/to/out.csv --all

Topic selection supports glob-style patterns via --topics, for example:

python -m blobjugglerpy --bag /path/to/bag --out out.csv --topics "/log*" "/sensors/*"

Batch mode recursively discovers bags and writes one output per bag. It uses the same topic flags as single-bag mode, but replaces --out with --output-dir:

python -m blobjugglerpy --batch /path/to/root --output-dir /path/to/exports --all
python -m blobjugglerpy --batch /path/to/root --output-dir /path/to/exports --topics "/log*" --per-topic

Note: You must specify either --all or --topics (supports globs) in both modes.

Command Line Help

$ python -m blobjugglerpy -h
usage: __main__.py [-h] (--bag BAG | --batch BATCH) [--out OUT] [--output-dir OUTPUT_DIR] [--topics [TOPICS ...]] [--all] [--per-topic] [--no-sort] [--overwrite] [--workers WORKERS]

Export ROS2 bag(s) to CSV.

options:
  -h, --help            show this help message and exit
  --bag BAG             Path to one rosbag2 directory (contains metadata.yaml)
  --batch BATCH         Root directory to search recursively for rosbag2 bags
  --out OUT             Output CSV path for --bag mode
  --output-dir OUTPUT_DIR
                        Output directory for --batch mode
  --topics [TOPICS ...]
                        Explicit list of topics to export
  --all                 Export all topics in the bag
  --per-topic           Write one CSV per topic instead of merged
  --no-sort             Do not sort by __time
  --overwrite           Overwrite existing CSV outputs
  --workers WORKERS     Number of worker processes for --batch

Installation

pip install git+https://github.com/incebellipipo/blobjugglerpy.git

Reading CSV data with pandas

The exported CSVs use comma as the value separator and may contain semicolons in column names (e.g., topic;field). Since the data is sparse, some rows may have missing values.

import pandas as pd

# Read the exported CSV
df = pd.read_csv('out.csv')

# Display the first few rows
print(df.head())

# Fill NaN values (sparse data) with 0 or interpolate
df_filled = df.fillna(0)

# Or use forward/backward fill for time-series data
df_interpolated = df.interpolate(method='linear')

About

ros2bag to CSV converter

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages