Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iamphytan/rosbag-topic-compare
PyPi package to assess ROS topic consistency in a rosbag dataset
https://github.com/iamphytan/rosbag-topic-compare
data-management robotics ros ros2 rosbag
Last synced: 22 days ago
JSON representation
PyPi package to assess ROS topic consistency in a rosbag dataset
- Host: GitHub
- URL: https://github.com/iamphytan/rosbag-topic-compare
- Owner: IamPhytan
- License: mit
- Created: 2022-11-02T02:10:51.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-10T14:31:17.000Z (about 2 years ago)
- Last Synced: 2025-01-20T12:52:13.194Z (23 days ago)
- Topics: data-management, robotics, ros, ros2, rosbag
- Language: Python
- Homepage: https://pypi.org/project/rosbag-topic-compare
- Size: 39.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.rst
- License: LICENSE
Awesome Lists containing this project
README
# rosbag-topic-compare
> Determine the topic consistency in a rosbag dataset
This package is a rewriting of [`rosbag-compare`](https://github.com/IamPhytan/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 :![Summary of missing topics](preview.png)
## Installation
`rosbag-topic-compare` can be installed from PyPi :
```console
$ pip install rosbag-topic-compare
```Or, if you want the plotting feature:
```console
$ 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.
```console
$ 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.
```console
$ rosbag-topic-compare -p /path/to/your/rosbag/dataset
```Here are all the CLI options of `rosbag-topic-compare`:
```console
$ rosbag-topic-compare -h
usage: rosbag-topic-compare [-h] [-m METADATA] [-p] [--fig FIG] bagfolderpositional arguments:
bagfolder Dataset directory pathoptions:
-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 :
```py
from rosbag_compare import BagTopicComparatordata_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_.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](https://flit.pypa.io) is used to package this module. Development packages can be installed using `flit` :
```console
$ python -m venv venv
$ source venv/bin/activate
$ pip install flit
$ flit install
```(Alternative) Development requirements can be installed using pip :
```console
$ python -m venv venv
$ source venv/bin/activate
$ pip install -r requirements/requirements-dev.txt
```## Acknowledgements
This package relies strongly on [`rosbags`](https://ternaris.gitlab.io/rosbags) for working with rosbags. Hats off to the team at [Ternaris](https://ternaris.com) for developing and maintaining it.
## License
This project is licensed under a [MIT](LICENSE) license