Compare topics between rosbags in a folder
Project description
rosbag-topic-compare
Determine the topic consistency in a rosbag dataset
This package is a rewriting of rosbag-compare for rosbags in both ROS1 and ROS2.
Use case
Say you have a bunch of rosbags inside a folder and you don't know whether or not all those rosbags have the same topics. rosbag-topic-compare will :
- retrieve the topics contained in each rosbag
- export a summary of the ros topics in a JSON file
- plot the topics that are missing for each rosbag :
Installation
rosbag-topic-compare can be installed from PyPi :
$ pip install rosbag-topic-compare
Or, if you want the plotting feature:
$ pip install rosbag-topic-compare[plot]
Usage
rosbag-topic-compare can be used both as a command line application and in Python code.
Command line
A basic use of rosbag-topic-compare is to simply call it with the path of the folder that contains rosbags. This will simply print out a YAML string with a summary of the comparison.
$ rosbag-topic-compare /path/to/folder/with/rosbags
You can also generate a figure that will show what topics are missing in each rosbag with the --plot/-p flag. This figure helps when you want to find out if all rosbags in a dataset contains all or some of the expected topics.
$ rosbag-topic-compare -p /path/to/your/rosbag/dataset
Here are all the CLI options of rosbag-topic-compare:
$ rosbag-topic-compare -h
usage: rosbag-topic-compare [-h] [-m METADATA] [-p] [--fig FIG] bagfolder
positional arguments:
bagfolder Dataset directory path
options:
-h, --help show this help message and exit
-m METADATA, --metadata METADATA
Metadata summary output path
-p, --plot Plotting mode : display a summary plot
--fig FIG, --summary-figure-path FIG
Path for saving a topic consistency figure
Python Code API
You can also call rosbag-topic-compare directly into your Python code :
from rosbag_compare import BagTopicComparator
data_path = "/path/to/folder/with/rosbags"
rbag_comp = BagTopicComparator(data_path)
# This step may take time as it open each rosbag separately
# Will show a progress bar
rbag_comp.extract_data()
# Export summary to a JSON file
rbag_comp.export_metadata() # Defaults to topics_<foldername>.json
rbag_comp.export_metadata("topics.json")
rbag_comp.export_metadata("topics.yaml")
# Generate a figure with the name of the
# missing topics for each rosbag
rbag_comp.plot() # Show figure
rbag_comp.plot(img_path="topics_summary.jpg") # Save figure to path
# Create a new comparator from exported metadata
rbag_comp = BagTopicComparator.from_json("topics.json")
rbag_comp = BagTopicComparator.from_yaml("topics.yaml")
Contributing
Pull requests are welcome and don't hesitate to open issues
(Recommended) flit is used to package this module. Development packages can be installed using flit :
$ python -m venv venv
$ source venv/bin/activate
$ pip install flit
$ flit install
(Alternative) Development requirements can be installed using pip :
$ python -m venv venv
$ source venv/bin/activate
$ pip install -r requirements/requirements-dev.txt
Acknowledgements
This package relies strongly on rosbags for working with rosbags. Hats off to the team at Ternaris for developing and maintaining it.
License
This project is licensed under a MIT license
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rosbag-topic-compare-0.0.3.tar.gz.
File metadata
- Download URL: rosbag-topic-compare-0.0.3.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c43f87e51e9c53d22c2715eba1caccedee3df441900a9cf24249ee925476b06
|
|
| MD5 |
f31e9ab0f8ab577ba2f0c5c32574433e
|
|
| BLAKE2b-256 |
c8ea0ed5334a8d0ffb80669304ed57d5fdf0255cf4a12e7966861cc7bbe8ecc1
|
File details
Details for the file rosbag_topic_compare-0.0.3-py3-none-any.whl.
File metadata
- Download URL: rosbag_topic_compare-0.0.3-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bb78175a0242f7cf51cb7b64003363262a65543c5b0ebdbe9c1cc77b8e3bcaf
|
|
| MD5 |
6106e48f624c4f9957b50fef01989a45
|
|
| BLAKE2b-256 |
0a4fc989484ad84725d433dfcb7f8bdfbd5047c4dfd8993dead42e4e3ef062ee
|