Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.bag2 files? #819

Closed
jhurliman opened this issue Jul 10, 2021 · 17 comments
Closed

.bag2 files? #819

jhurliman opened this issue Jul 10, 2021 · 17 comments
Labels
enhancement New feature or request

Comments

@jhurliman
Copy link

Description

What do people think about introducing the option of a single file container for ROS2 bags? I'm thinking something like a tar file with the extension .bag2 since compression is handled at a lower level, but I mostly just want to start the discussion and get a temperature read.

The practical use cases are around storage and sharing. Uploading a single file for cloud storage can be an atomic operation (it's either uploaded or not, downstream processing actions can be triggered off the upload successfully completing) and verifying the upload succeeded is a more straightforward hash check of a single file where uploading a folder gets more into rsync territory. When sharing files with coworkers or on the Internet, it's convenient to post a single file for download instead of figuring out how to share a folder full of files (and confirm that you're received all of the files on the receiving end).

@jhurliman jhurliman added the enhancement New feature or request label Jul 10, 2021
@danthony06
Copy link

Since no one else is jumping in, I'll add my 2 cents. Since we're still mostly on ROS 1, we typically fragment the bags according to file size while recording them, so during a field experiment we usually limit a bag to a couple of gigs. Our rationale is:

  1. If the system crashes, it reduces our chances of losing all of the data from a trial, or having to do some kind of file recovery to fix any issues with an unexpected crash.
  2. Since we're frequently in areas with poor network connectivity, it gives us a way to deliver a smaller amount of information back to our home location without needing to postprocess and filter a bag in the field.
  3. Large ROS1 bags are generally painful to work with because of how the file access works. Principally, I think it does linear reads, so if I end up with a 60 gig bag file, opening and getting to that last gig of information is not a lot of fun.

I think ROS2's switch to sqlite on the backend makes point 3 less important, but the first two points still stand. I do think the single container helps when postprocessing, because it's a lot more convenient to pass in a single large file to an analysis or visualization script. It's also a lot more convenient for sharing, as you pointed out.

@emersonknapp
Copy link
Collaborator

I'm not opposed to this idea in principle - though I'd want to make sure we get the user experience right without complicating the options too much, and still support the other format.

The sqlite3 databases already encode the contents of the metadata.yaml file for a given file, so theoretically every .db3 file is independently usable, though right now the Reader APIs expect an aggregated metadata file to read. We could easily add an option to fall-back to the storage implementation's understanding of the metadata, as long as we make clear the expectation that a storage implementation must encode the metadata.

@danthony06
Copy link

danthony06 commented Jul 15, 2021

Agreed. I think I'd want at least these two options.

  1. At record time, pass a command line argument like ros2 bag record --monolith ...
  2. As a post processing step, something like ros2 bag consolidate <path_to_bags>

The rationale for the first one is I can see users wanting a simple command to get this behavior at recording time. The second case would be for something like my usage pattern, where I have my field data fragmented into a bunch of files, but want an easy way to upload it to a colleague or simplify post-processing and analysis of it.

Is it possible to get this kind of behavior with our current set of command line arguments and utilities?

@chaoflow
Copy link

The sqlite3 databases already encode the contents of the metadata.yaml file for a given file, so theoretically every .db3 file is independently usable, ...

@emersonknapp Does this mean that metadata.yaml is purely redundant and all information to be stored in the db3 files? If yes, we need to take this into account in #782 as well.

@MichaelOrlov
Copy link
Contributor

@chaoflow As far as I am understanding concept behind metadata.yaml is that it's playing role to provide easy accessible, human readable information about stored metadata without access to the databases via SQL requests.
Main purpose of metadata.yaml is to duplicate metadata from db3 file but not to store it in the first place.

It's comfy when you deal with multiple recordings and want to know what inside of these recordings without loading full stack, - you can simply open metadata.yaml in text editor.

@Karsten1987
Copy link
Collaborator

I see the argument of sharing (uploading/downloading) a bag file and thus have a single file containing all the info. I would say no to making it a single file by default for reasons being mentioned in this thread here already - i.e. composing various individual bag files via the metadata.yaml.
However, I could see this fit quite nicely in an additional verb to ros2 bag, something in the style of ros2 bag package <path/to/metadata.yaml>. That way a user can explicitly pack all related files into a common file and adapt the metadata.yaml file accordingly. tar seems like an obvious choice here, but keep in mind that we want to support the feature on all tier 1 platforms - Windows being one of them.

@amacneil
Copy link
Contributor

I only just came across this thread, so cross referencing it with #855 since some similar discussions are happening over there.

@Flova
Copy link

Flova commented Mar 13, 2022

Quite some time since the last comment, but I think that the new way of having a folder is quite painful to use. It is not that bad, but another minor inconvenience in ROS2. Many file formats (e.g. epub, apk, ...) consist of an internal folder structure that is hidden by a tar or zip archive. Accessing the metadata is quite easy as one just needs to grab an archive tool of his choice and view the metadata files. In rosbag2 it is the other way around. Everybody needs to grab such a tool if the bag should be transferred/downloaded/accessed. All of this just for the sake of easier access to the metadata. I hope nobody takes that personally, overall I think that e.g. sqlite is a great choice for the backend and appreciate the work that went into this. This is just some feedback from somebody who uses ros bags a lot and is not that involved in the development.

@jhurliman
Copy link
Author

The MCAP storage plugin (https://github.com/ros-tooling/rosbag2_storage_mcap) is ready for testing. Once it has a few users that can confirm it's working for their day-to-day usage, we'll publish to rolling then humble as an apt package and close this issue out.

@emersonknapp
Copy link
Collaborator

This is related to work on #972 and #1074

@amacneil
Copy link
Contributor

amacneil commented Sep 13, 2022

We took the ideas from this thread, #782, #855, and several others and incorporated them into the design of MCAP, a highly efficient, self-contained recording format for ROS 2 and more.

A ROS 2 MCAP storage plugin is available for Foxy, Galactic, Humble and Rolling, and using it is as simple as ros2 bag record -s mcap.

Therefore, I think we should close this issue now.

@danthony06
Copy link

danthony06 commented Sep 13, 2022 via email

@amacneil
Copy link
Contributor

amacneil commented Sep 13, 2022

@danthony06 ROS 2 in general does not support what you are describing. In order to connect and communicate with a remote ROS 2 node, you must have the message definitions locally. This is a regression from ROS 1 and discussed here.

Assuming you do have a copy of the message definitions available locally, MCAP will find them and store in the file for future use.

@emersonknapp
Copy link
Collaborator

emersonknapp commented Sep 13, 2022

I am going to close this as implemented - we now allow for playing self-contained ROS 2 individual bag files.

There may be further related features, like the discussion about message types above, but that is beyond the scope of this ticket and should be tracked independently.

@danthony06
Copy link

danthony06 commented Oct 11, 2022 via email

@amacneil
Copy link
Contributor

amacneil commented Oct 12, 2022

@danthony06 FYI there is some other work being done by open robotics which will hopefully give us runtime message definitions for the next major version of ROS 2 (Iron).

@emersonknapp
Copy link
Collaborator

Closing this issue was not meant to imply #782 is also closed, it is still open - we can maybe move any discussion on that particular feature to that issue, so as not to lose any extra context!

My understanding of the scope of this issues is "rosbag2 can use standalone files", which is now a capability. Best not to pack too much into an individual issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants