You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use the API to save a message to a bag.
I am using rosbag2_cpp::writers::SequentialWriter to open a bag (which does not exist yet, expecting the API to create it) then write to it.
Expected Behavior
Creation of a bag file in the URI specified on the use of SequentialWriter::open.
Actual Behavior
No bag file is being created. I am getting the error messages below and the code stops.
[rosbag2_storage]: Could not open 'my_bag/my_bag_0' with 'sqlite3'. Error: Failed to setup storage. Error: Could not read-write open database. SQLite error (14): unable to open database file
[ERROR] [1593304125.490127311] [rosbag2_storage]: Could not load/open plugin with storage id 'sqlite3'.
unknown file: Failure C++ exception with description "No storage could be initialized. Abort"
To Reproduce
That's part of the code I am using, bag->open(...) is what cause all the error messages:
rosbag2_cpp::StorageOptions storage_options = rosbag2_cpp::StorageOptions{};
storage_options.uri = "my_bag";
storage_options.storage_id = "sqlite3";
auto bag = std::make_unique<rosbag2_cpp::writers::SequentialWriter>();
bag->open(storage_options, {"rmw_format", "rmw_format"});
I have dug a bit into the code, it seems to me that SqliteWrapper::SqliteWrapper is the method that is supposed to create a db3 file in whatever URI passed to. I did some tests and this function can only create db3 files in existing directories and will fail to create a db if the directory doesn't exist.
I couldn't see a place where non-existent URIs get created(maybe I am missing something). I think the resolution for this problem could be checking the existence of the URI and creating it if it doesn't exist, this can maybe be performed in this function:
I guess by now we have enough functionality in rcutils/rcpputils to integrate that work into rosbag2_cpp. So thanks a lot for opening the discussion here.
Description
I am trying to use the API to save a message to a bag.
I am using
rosbag2_cpp::writers::SequentialWriter
to open a bag (which does not exist yet, expecting the API to create it) then write to it.Expected Behavior
Creation of a bag file in the URI specified on the use of
SequentialWriter::open
.Actual Behavior
No bag file is being created. I am getting the error messages below and the code stops.
To Reproduce
That's part of the code I am using,
bag->open(...)
is what cause all the error messages:System
Additional context
I have dug a bit into the code, it seems to me that
SqliteWrapper::SqliteWrapper
is the method that is supposed to create a db3 file in whatever URI passed to. I did some tests and this function can only create db3 files in existing directories and will fail to create a db if the directory doesn't exist.rosbag2/rosbag2_storage_default_plugins/src/rosbag2_storage_default_plugins/sqlite/sqlite_wrapper.cpp
Lines 50 to 52 in a4d49db
I couldn't see a place where non-existent URIs get created(maybe I am missing something). I think the resolution for this problem could be checking the existence of the URI and creating it if it doesn't exist, this can maybe be performed in this function:
rosbag2/rosbag2_cpp/src/rosbag2_cpp/writers/sequential_writer.cpp
Line 36 in a4d49db
Apologies if my problem analysis is wrong (likely :-)), Please let me know if I need to provide any extra info.
Thanks in advance!
The text was updated successfully, but these errors were encountered: