Remove topics from rosbags
Project description
rosbag-topic-remove
Filter out topics from a rosbag
Use case
Say you have too much topics in a rosbag (ROS1 or ROS2) and that you want to keep a copy of this rosbag without data from a specific sensor. rosbag-topic-remove
will :
- Filter out topics based on their name
- Filter out topics based on glob-like wildcard patterns
- Preserve your original rosbag
- Convert your rosbag from ROS1 to ROS2, if needed
Installation
rosbag-topic-remove
can be installed from PyPi :
pip install rosbag-topic-remove
Usage
rosbag-topic-remove
can be used both as a command line application and in Python code.
Command line
A basic use of rosbag-topic-remove
is to simply call it from the command line.
rosbag-topic-remove /path/to/folder/with/rosbags
Here are all the CLI options of rosbag-topic-remove
:
$ rosbag-topic-remove -h
usage: rosbag-topic-remove [-h] [-o OUTBAG] [-t TOPICS [TOPICS ...]] [-f]
inbag
positional arguments:
inbag Input bag
options:
-h, --help show this help message and exit
-o OUTBAG, --output OUTBAG, --outbag OUTBAG
Filtered bag
-t TOPICS [TOPICS ...], --topics TOPICS [TOPICS ...]
Topics to remove from the rosbag
-f, --force Force output file overwriting
Python Code API
You can also call rosbag-topic-remove
directly into your Python code :
from rosbag_topic_remove import BagTopicRemover
data_path = "path/to/a/rosbag.bag" # ROS1
data_path = "path/to/a/rosbag" # ROS2
rbag_rem = BagTopicRemover(data_path)
# Change the input bag
rbag_rem.inbag = "path/to/another/rosbag"
# Remove /cmd_vel
rbag_rem.remove("/cmd_vel")
# Remove /cmd_vel
rbag_rem.remove("/cmd_vel")
# Remove all camera info topics
rbag_rem.remove("/*/camera_info")
# Remove all topics from the IMU and from the GPS
rbag_rem.remove(("/imu/*", "/gps/*"))
# Export a rosbag with all topics filtered
rbag_rem.export("path/to/save/this/filtered/rosbag.bag") # ROS1
rbag_rem.export("path/to/save/that/filtered/rosbag") # ROS2
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
Hashes for rosbag-topic-remove-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ca74873c19021e5dc191e56c409a80091d500ca5800c6c48de10e550dc79d64 |
|
MD5 | 606c90dbcc64f66ae40a10d12304166b |
|
BLAKE2b-256 | eda8c2012a9ee67e90e131f8caca4a1f36c49e0315ab80df1ef6dda85cae7895 |
Hashes for rosbag_topic_remove-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc038804abe868b544f8880b9b57042623300e4812ba37942da10a42752e0501 |
|
MD5 | 7003329c95c76a9fb445206785a7eadc |
|
BLAKE2b-256 | 438f46879c9582706a7f3638480614b17dfab1f5b99f18612cfb84b8bae61226 |