Giter Club home page Giter Club logo

ros2bag_tools's Introduction

ROS2 bag tools

This package is built and tested with ROS2 galactic.

This package adds verb extensions to the ros2bag cli.

Verb Usage
cut cut time slice by wall time or duration offset
drop drop X out of every Y messages of a topic
export export data to other formats
extract extract topics by name
merge merge multiple bags into one
plot plot message data to a new window
reframe change frame_id on messages with headers
rename change name of a topic
restamp for all messages with headers, change the bag timestamp to their header stamp
replace replace messages of a specific topic with message data specified in a yaml file
summary print summary on data to stdout
video show or write video of image data

You can check detailed usage information with ros2 bag $VERB --help.

Each command writes a new output bag on disk. If you need to chain multiple commands together, you can use ros2 bag process to process all messages in-memory and write only one output bag. To use it, create a config file that contains one line per command, with the same arguments as the cli interface.

For example create a file named process.config containing those lines:

cut --duration 10
extract -t /image_rect
restamp

and run ros2 bag process -c process.config in.bag -o out.bag to crop to the first 10 seconds, keep only the /image_rect topic and restamp the remaining messages in one go.

Python API

The verbs are built on top of utilities in rosbag2_tools.

You can iterate message data using BagView.

from rosbag2_tools.bag_view import BagView
reader = SequentialReader()
storage_options = StorageOptions(uri='test/range.bag', storage_id='sqlite3')
converter_options = ConverterOptions(
    input_serialization_format='cdr',
    output_serialization_format='cdr')
reader.open(storage_options, converter_options)
for _, range_msg, _ in BagView(reader):
    print('r', range_msg.range)

Or read topics as pandas data frames.

from rosbag2_tools.data_frame import read_data_frames
reader = SequentialReader()
storage_options = StorageOptions(uri='test/range.bag', storage_id='sqlite3')
converter_options = ConverterOptions(
    input_serialization_format='cdr',
    output_serialization_format='cdr')
reader.open(storage_options, converter_options)
dfs = read_data_frames(BagView(reader))
dfs['/range'].summary()

Current limitations

  • Tools do not operate in-place, they all create new output bags, potentially doubling the required disk space
  • The time filters used in the cut verb truncate timestamps to the microsecond, due to the precision loss of the pybind11-conversion of C++ chrono time objects to python3 datetime objects. Thus, filters are not sufficiently precise to handle timestamp deltas below 1000ns.

ros2bag_tools's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.