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 additional examples for reading ROSBag data and serialized messages #1449

Closed
MaxFleur opened this issue Aug 22, 2023 · 5 comments · Fixed by #1683
Closed

Add additional examples for reading ROSBag data and serialized messages #1449

MaxFleur opened this issue Aug 22, 2023 · 5 comments · Fixed by #1683
Assignees
Labels
enhancement New feature or request

Comments

@MaxFleur
Copy link

Description

Currently, the ROSBag2 examples contain three different examples for writing data to a ROSBag via C++ or Python. However, there are no specific examples of reading data from ROSBags (neither for the standard reader or the sequential reader). In addition, the writing examples do not show how to serialize various messages before writing them to a bag file.
Inside the file under rosbag2_tests/test/rosbag2_tests/test_rosbag2_cpp_api.cpp, there are test cases for reading data and also for the message serialization. These helped me when using the ROSBag2 API, but in my opinion, a better idea is to create dedicated examples, because the unit tests should be meant solely for testing.

Completion Criteria

  • Example for reading ROSBag data using a simple reader (rosbag2_cpp::Reader)
  • Example for reading ROSBag data using a sequential reader (rosbag2_cpp::SequentialReader)
  • Example for writing ROSBag data using serialized messages (rclcpp::SerializedMessage and rclcpp::Serialization<>)
@MaxFleur MaxFleur added the enhancement New feature or request label Aug 22, 2023
@Ryanf55
Copy link

Ryanf55 commented Feb 16, 2024

This one covers reading:
https://docs.ros.org/en/rolling/Tutorials/Advanced/Reading-From-A-Bag-File-CPP.html

Unfortunately, if the topic name is the wrong topic type than what is attempted to deserialize to, then there is a crash.

@fujitatomoya
Copy link
Contributor

IMO we could have rosbag2_examples_<lang>::SimpleBagPlayer and https://docs.ros.org/en/rolling/Tutorials/Advanced/Reading-From-A-Bag-File-CPP.html link it as an example.

This seems good-first-issue, probably we can tag this issue with help-wanted? 😄

@Ryanf55
Copy link

Ryanf55 commented Feb 16, 2024

Yea.

The existing tutorial can be improved to make sure the new code prevents exceptions thrown in RMW by trying to deserialize the wrong message type and making assumptions about what's in the bag.

ANYbotics/grid_map#401
^ See here for info and the associated PR for the fix.

@sangteak601
Copy link

I want to take a look at this.
@MichaelOrlov Do you mind assigning this to me ?

@MichaelOrlov
Copy link
Contributor

@sangteak601 Thank you for being willing to help with this. You have got it 😉

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
5 participants