Storage Configuration for Mcap with rosbag2 API

With using the cli, you can use a config file to configure mcap.

ros2 bag record -s mcap --storage-config-file …

I want to change the MCAP storage options like compression, chunksize and so on with the rosbag2 API either python or c++
How can I do this with the API if I want to write to a bag from my node directly? Are there any good tutorials similar to this? Recording a bag from a node (Python) — ROS 2 Documentation: Humble documentation

You can use mcap and compression like this in cpp:

    rosbag2_storage::StorageOptions storage_options;
    storage_options.storage_id = "mcap";
    storage_options.storage_preset_profile = "zstd_fast";

Should work the same for python

The presets are documented here

1 Like

Apparently there is also the option: storage_options.storage_config_uri

€: For Python it is available since Humble, I guess for cpp in earlier versions.

Not sure if this is helpful, but the nml_bag package has an example (also as .py) that sets storage options and writes a bag programmatically in Python.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.