-
Notifications
You must be signed in to change notification settings - Fork 251
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
rosbag2_py reader and writer #308
Conversation
Signed-off-by: Jacob Perron <jacob@openrobotics.org> (cherry picked from commit f2ec0b7)
Expose the sequential reader to iterate over messages from Python. Signed-off-by: Jacob Perron <jacob@openrobotics.org> (cherry picked from commit dc68894)
Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit 91f6763)
Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit deafbf8)
Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit da561cc)
Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit 4a4e1b8)
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Thanks! Not too familiar with pybind but is it possible to have this binding for the general |
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
@piraka9011 Thanks for the review! f8c4391 wraps around Reader. The type e.g. |
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
Signed-off-by: Mabel Zhang <mabel@openrobotics.org>
I think this is ready if I can get another approval. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't had a change to test it yet, but this looks good to me so far.
But I guess it would be good to have somebody else look over it as well.
@emersonknapp Could you take a last pass on this PR? We need one more approval before merging. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good, thanks for going through all the revisions on it
I think this change has introduced a build failure in the nightly clang job: https://ci.ros2.org/view/nightly/job/nightly_linux_clang_libcxx/513
|
In addition to the compilation failure mentioned above there also appear to be issues on Windows Debug which I've opened #504 to track. |
This reverts commit 038bae2.
Noob question, but how do I actually use rosbag2_py? I have installed it as per the instructions on the rosbag2 README,
but I do not see it in ros2 pkg list and when I try to import it in python I get an error Running on Ubuntu 20.04 on Foxy. Thanks in advance! |
Hi @evclark, for future reference, please post questions as a new Issue or on ROS Answers, as opposed to commenting on a merged PR. First, you are using Foxy, but you installed the packages for crystal? That does not look right. Your distro should be Since this PR was merged very recently, and we had just fixed some issues and re-enabled rosbag2_py 21 days ago, I don't know if it's included in |
Noted, will do, thanks
Ah yes, sorry, copy/paste error from the README, I did install the foxy, not crystal, packages.
It appears not to be. I'll try building from source, thanks! |
FWIW, I don't expect this feature to land in Foxy. While we wait for Galactic to be released, you can build from source. Once a new release is made into Rolling, you should be able to install the binary. |
Building from source including rosbag2_py on foxy and not against Rolling worked for me with
Only small unresolvable conflict is inside a workflow file. Is there a better solution? I think lot of people would be happy having this feature in foxy! Disclaimer: I did not try to read a bagfile yet. |
In retrospect, it may be easy to backport this new package to Foxy (assuming it's not relying on anything new in Galactic). Pinging maintainers to see if there is any opposition, @mjeronimo @ros2/tooling-approvers |
It may be easy, but the APIs that it binds to may have changed. I'm all for someone trying it out, no opposition from me - I'm just not 100% confident it will be easy |
* Initialize new package rosbag2_py Signed-off-by: Jacob Perron <jacob@openrobotics.org> (cherry picked from commit f2ec0b7) * Proof-of-concept implementation using pybind11 Expose the sequential reader to iterate over messages from Python. Signed-off-by: Jacob Perron <jacob@openrobotics.org> (cherry picked from commit dc68894) * pybind StorageOptions and ConverterOptions; linter fixes Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit 91f6763) * return timestamp Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit deafbf8) * simplify binding of structs Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit da561cc) * pybind TopicMetadata Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit 4a4e1b8) * namespace rosbag2 -> rosbag2_cpp Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * small fixes Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * initial pytests Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * wrap Reader instead of SequentialReader Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * small fixes for PR comments Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * change workflow to autotest feature branch Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * revert workflow Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * added writer and writer tests Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * fix test path setup Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * fix and make more rigorous writer test Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * wrapper and test for topic filter Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * linters. change pybind package Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * simplify verbose import Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * tidy up Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * explicit subclasses of Reader and Writer Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * Use template specialization instead of inheritence This makes the implementation slightly more compact. And adding a new specialization should be more straight forward as we only have to modify the cpp file in one place. Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Remove temporary variable Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Remove unused member variable Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Move to initializer list Signed-off-by: Jacob Perron <jacob@openrobotics.org> * refactor into reader writer storage Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * cleanup includes Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * switch back to pybind11_vendor Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * Packages dependency for CI Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * printout to debug CI test failure Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * use tempfile for writer test, add exec_depend Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * remove exec_depend Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * use pytest fixture tmp_path; add rosbag2_py to rosbag2 Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add makedirs back to see CI result Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * fix import error Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * cleanup Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add modules explicitly for windows CI Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * cleanup Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * try more <test_depend>s for mac test failure Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * wrap structs with named arguments for Python keyword params Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add pytest.ini Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add rosbag db3-shm and db3-wal files for macOS test Signed-off-by: Mabel Zhang <mabel@openrobotics.org> Co-authored-by: Jacob Perron <jacob@openrobotics.org> Co-authored-by: Andreas Klintberg <ankl@kth.se>
* Initialize new package rosbag2_py Signed-off-by: Jacob Perron <jacob@openrobotics.org> (cherry picked from commit f2ec0b7) * Proof-of-concept implementation using pybind11 Expose the sequential reader to iterate over messages from Python. Signed-off-by: Jacob Perron <jacob@openrobotics.org> (cherry picked from commit dc68894) * pybind StorageOptions and ConverterOptions; linter fixes Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit 91f6763) * return timestamp Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit deafbf8) * simplify binding of structs Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit da561cc) * pybind TopicMetadata Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit 4a4e1b8) * namespace rosbag2 -> rosbag2_cpp Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * small fixes Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * initial pytests Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * wrap Reader instead of SequentialReader Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * small fixes for PR comments Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * change workflow to autotest feature branch Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * revert workflow Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * added writer and writer tests Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * fix test path setup Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * fix and make more rigorous writer test Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * wrapper and test for topic filter Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * linters. change pybind package Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * simplify verbose import Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * tidy up Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * explicit subclasses of Reader and Writer Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * Use template specialization instead of inheritence This makes the implementation slightly more compact. And adding a new specialization should be more straight forward as we only have to modify the cpp file in one place. Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Remove temporary variable Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Remove unused member variable Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Move to initializer list Signed-off-by: Jacob Perron <jacob@openrobotics.org> * refactor into reader writer storage Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * cleanup includes Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * switch back to pybind11_vendor Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * Packages dependency for CI Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * printout to debug CI test failure Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * use tempfile for writer test, add exec_depend Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * remove exec_depend Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * use pytest fixture tmp_path; add rosbag2_py to rosbag2 Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add makedirs back to see CI result Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * fix import error Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * cleanup Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add modules explicitly for windows CI Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * cleanup Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * try more <test_depend>s for mac test failure Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * wrap structs with named arguments for Python keyword params Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add pytest.ini Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add rosbag db3-shm and db3-wal files for macOS test Signed-off-by: Mabel Zhang <mabel@openrobotics.org> Co-authored-by: Jacob Perron <jacob@openrobotics.org> Co-authored-by: Andreas Klintberg <ankl@kth.se>
* Initialize new package rosbag2_py Signed-off-by: Jacob Perron <jacob@openrobotics.org> (cherry picked from commit f2ec0b7) * Proof-of-concept implementation using pybind11 Expose the sequential reader to iterate over messages from Python. Signed-off-by: Jacob Perron <jacob@openrobotics.org> (cherry picked from commit dc68894) * pybind StorageOptions and ConverterOptions; linter fixes Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit 91f6763) * return timestamp Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit deafbf8) * simplify binding of structs Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit da561cc) * pybind TopicMetadata Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit 4a4e1b8) * namespace rosbag2 -> rosbag2_cpp Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * small fixes Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * initial pytests Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * wrap Reader instead of SequentialReader Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * small fixes for PR comments Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * change workflow to autotest feature branch Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * revert workflow Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * added writer and writer tests Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * fix test path setup Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * fix and make more rigorous writer test Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * wrapper and test for topic filter Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * linters. change pybind package Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * simplify verbose import Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * tidy up Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * explicit subclasses of Reader and Writer Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * Use template specialization instead of inheritence This makes the implementation slightly more compact. And adding a new specialization should be more straight forward as we only have to modify the cpp file in one place. Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Remove temporary variable Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Remove unused member variable Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Move to initializer list Signed-off-by: Jacob Perron <jacob@openrobotics.org> * refactor into reader writer storage Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * cleanup includes Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * switch back to pybind11_vendor Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * Packages dependency for CI Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * printout to debug CI test failure Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * use tempfile for writer test, add exec_depend Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * remove exec_depend Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * use pytest fixture tmp_path; add rosbag2_py to rosbag2 Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add makedirs back to see CI result Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * fix import error Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * cleanup Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add modules explicitly for windows CI Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * cleanup Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * try more <test_depend>s for mac test failure Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * wrap structs with named arguments for Python keyword params Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add pytest.ini Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add rosbag db3-shm and db3-wal files for macOS test Signed-off-by: Mabel Zhang <mabel@openrobotics.org> Co-authored-by: Jacob Perron <jacob@openrobotics.org> Co-authored-by: Andreas Klintberg <ankl@kth.se> Signed-off-by: Alexander Gutenkunst <alex.gutenkunst+github.com>
* Initialize new package rosbag2_py Signed-off-by: Jacob Perron <jacob@openrobotics.org> (cherry picked from commit f2ec0b7) * Proof-of-concept implementation using pybind11 Expose the sequential reader to iterate over messages from Python. Signed-off-by: Jacob Perron <jacob@openrobotics.org> (cherry picked from commit dc68894) * pybind StorageOptions and ConverterOptions; linter fixes Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit 91f6763) * return timestamp Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit deafbf8) * simplify binding of structs Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit da561cc) * pybind TopicMetadata Signed-off-by: Mabel Zhang <mabel@openrobotics.org> (cherry picked from commit 4a4e1b8) * namespace rosbag2 -> rosbag2_cpp Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * small fixes Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * initial pytests Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * wrap Reader instead of SequentialReader Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * small fixes for PR comments Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * change workflow to autotest feature branch Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * revert workflow Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * added writer and writer tests Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * fix test path setup Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * fix and make more rigorous writer test Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * wrapper and test for topic filter Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * linters. change pybind package Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * simplify verbose import Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * tidy up Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * explicit subclasses of Reader and Writer Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * Use template specialization instead of inheritence This makes the implementation slightly more compact. And adding a new specialization should be more straight forward as we only have to modify the cpp file in one place. Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Remove temporary variable Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Remove unused member variable Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Move to initializer list Signed-off-by: Jacob Perron <jacob@openrobotics.org> * refactor into reader writer storage Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * cleanup includes Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * switch back to pybind11_vendor Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * Packages dependency for CI Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * printout to debug CI test failure Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * use tempfile for writer test, add exec_depend Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * remove exec_depend Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * use pytest fixture tmp_path; add rosbag2_py to rosbag2 Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add makedirs back to see CI result Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * fix import error Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * cleanup Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add modules explicitly for windows CI Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * cleanup Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * try more <test_depend>s for mac test failure Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * wrap structs with named arguments for Python keyword params Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add pytest.ini Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add rosbag db3-shm and db3-wal files for macOS test Signed-off-by: Mabel Zhang <mabel@openrobotics.org> Co-authored-by: Jacob Perron <jacob@openrobotics.org> Co-authored-by: Andreas Klintberg <ankl@kth.se> Signed-off-by: Emerson Knapp <eknapp@amazon.com>
Initial reader functionalities for rosbag2_py.
Dependencies:
Example usage is
here (minus the lines about StorageFilter which need #302 and Python binding)in the test.