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

Add convert verb #306

Closed
wants to merge 7 commits into from
Closed

Add convert verb #306

wants to merge 7 commits into from

Conversation

Kettenhoax
Copy link

Adds a convert verb to convert bags between storages and serialization formats. Tested with a conversion of rosbag2_bag_v2 to sqlite3, but I was unsure whether to add a bag to the repository for an integration test, because it would require rosbag2_bag_v2 as test dependency.

Should close #163

Marcel Zeilinger added 4 commits March 1, 2020 23:33
Signed-off-by: Marcel Zeilinger <[email protected]>
Signed-off-by: Marcel Zeilinger <[email protected]>
Signed-off-by: Marcel Zeilinger <[email protected]>
Copy link
Collaborator

@Karsten1987 Karsten1987 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. A convert tool is highly appreciated.

I am requesting changes though as I believe that this logic should not live in rosbag2_transport but can rather be handled solely with rosbag2_cpp API.

@@ -0,0 +1,84 @@
# Copyright 2018 Open Source Robotics Foundation, Inc.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

year 2020

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same below

help='destination of the bagfile to create, \
defaults to a timestamped folder in the current directory')
parser.add_argument(
'-s', '--storage', default='sqlite3',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for a convert verb I would consider renaming this to --input-storage to highlight the conversion from input to output.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not completely sure a default for input makes sense here. The storage identifier might be guessed from the metadata.yaml if present, but otherwise this has to be specified.
It makes more sense for me to have it defaulted to sqlite3 on the output side.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In current master, the play and info verbs also set the input storage argument default to sqlite3, so I thought it best to keep the convention. I agree that it should be guessed, but the necessary api doesn't seem to be available in python, and IMO shouldn't be added in this PR.

I would rename it to --input-storage, remove the default and set required=True. I would also remove the short -s and not add -i to avoid confusion with -o, which is a filepath rather than storage specifier.

@Karsten1987 Karsten1987 mentioned this pull request Mar 2, 2020
@togaen
Copy link

togaen commented Jun 2, 2020

@Kettenhoax @Karsten1987 Any updates on this? It would be really great to have. I happy to help out if I can.

@Kettenhoax
Copy link
Author

I'm still interested in merging this and have been waiting on #232, which seems to add the required Python API to implement the requested changes.

@jacobperron
Copy link
Member

I'm also interested in this.

@Kettenhoax, #232 has been resolved. There's now a basic Python API. I'm not sure if it contains all the functionality needed for this feature, but I'm happy to help add/review PRs adding what's missing.

@jacobperron
Copy link
Member

@Kettenhoax Friendly ping. Let me know if you have plans to work on this, otherwise, I may have some spare cycles soon to help push it forward.

@Kettenhoax
Copy link
Author

Yes, I can work on this next few days.

@Karsten1987 or @jacobperron Looking at the current master, could you clarify if the preferred way to implement this is either

  1. using the existing Reader and Writer api in rosbag_py to iterate over messages in the verb extension point, or
  2. add a Converter api to rosbag_py and invoke it in ros2bag

In both cases as dependency on rosbag_py will need to be added to ros2bag.

@jacobperron
Copy link
Member

@Kettenhoax For me, adding a converter API to rosbag2_py is the preferred option. This allows other Python applications to take advantage of the functionality without having to go through the CLI verb.

@jacobperron
Copy link
Member

@Kettenhoax When adding the new API to rosbag2_py, it would be best to do it in a separate PR from the changes to the CLI. This will help with the review process and maintenance 🙂

@jacobperron
Copy link
Member

@Kettenhoax Friendly ping 🙂 Any update?

@Kettenhoax Kettenhoax requested a review from a team as a code owner December 3, 2020 13:17
@Kettenhoax Kettenhoax requested review from thomas-moulard and jikawa-az and removed request for a team December 3, 2020 13:17
@Kettenhoax
Copy link
Author

Yes, I've started to extend rosbag2_py API by a converter. However, I've run into roadblocks when implementing compression. Currently a caller of rosbag2_py decides whether to instantiate a compression- or standard reader/writer. The way I think this API is meant to be used, a converter should be passed an already-instantiated reader and writer.

As PoC I tried to do this in the verb only, without extending rosbag2_py. Unfortunately rosbag2_py.SequentialCompressionWriter seems to lack a parameter for the compression options.

We also need a python-exposed API to determine whether a bag is compressed and instantiate the correct reader. Currently this is only done in rosbag2_transport_python.cpp.

@jacobperron It would be great if you could do the necessary rosbag2_py extensions. You can check da6c184 for how I'm trying to use rosbag2_py

@emersonknapp
Copy link
Collaborator

A note of interest - we have plans to consolidate the compression/standard readers/writers - having realized that the split mostly leads to code duplication that is hard to maintain. Unfortunately that work hasn't started yet - I know it would make this easier

@ZhenshengLee
Copy link

Any update?

@emersonknapp emersonknapp removed the request for review from thomas-moulard July 7, 2021 17:49
@emersonknapp emersonknapp self-requested a review July 7, 2021 17:49
@emersonknapp
Copy link
Collaborator

Closing this as stale in favor of the work going on by @gbiggs for #831 - that work will implement most if not all of this proposal.

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

Successfully merging this pull request may close these issues.

ros2bag convert verb
6 participants