ros2/rosbag2

Setting compression mode when using rosbag2_py.SequentialCompressionWriter

bmdyrdal opened this issue · 7 comments

Hi folks,

I'm writing a component for recording specific topics, and wanted to use the rosbag2_py library.
I'm having some difficulties finding out how I can set the compression mode? I see that you can set it in the bagmetadata, but I don't see how I can use that?
Anyone who has any examples of how I can do this?

Thanks in advance!

@bmdyrdal What storage backend and ROS 2 distro are you going to use?

As far as I see the constructor of the Sequential Compression Writer has an argument of type rosbag2_compression::CompressionOptions

explicit SequentialCompressionWriter(
const rosbag2_compression::CompressionOptions & compression_options =
rosbag2_compression::CompressionOptions());

However, this argument is not bound to Python accordingly in rosbag2_py

pybind11::class_<PyCompressionWriter>(m, "SequentialCompressionWriter")
.def(pybind11::init())

Furthermore, the rosbag2_compression::CompressionOptions is not bound to Python.

So wouldn't it be correct to adapt the pybind11 code in rosbag2_py to adapt the API of the cpp version?

@MichaelOrlov Using Humble, store it using sqlite3 in our file system.
Works fine using it from the command line.

@simonsag96 Is spot on with his comment! 👍

While waiting for this I ended up writing a python node which starts the recording as a subprocess.

@bmdyrdal @simonsag96 Yes. The solution would be to provide pybind11 code in rosbag2_py package to map rosbag2_compression::CompressionOptions to Python and use it as the default parameter in the Python version of the SequentialCompressionWriter.

But unfortunately, I don't have time for this task. If some of you can provide a PR it would be great, otherwise, this task will go in the backlog.

Thanks for your answer @MichaelOrlov!

I could implement this over the course of next week!

@simonsag96 I needed this myself today, so I put together this PR: #1425