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

Fix startTime and endTime computation when chunks are not sorted #111

Merged
merged 2 commits into from
Jun 22, 2022

Conversation

pankdm
Copy link
Contributor

@pankdm pankdm commented Jun 22, 2022

From reading discussion ros/ros_comm#952 about python implementation this seems like a similar bug on rosbag.js. Fixing this by iterating through all chunks not just first and last.

Note: I used the following script to create fixture bag (reference):

from rosbag import Bag
from rospy import Time
from std_msgs.msg import String

b = Bag("example-unsorted-chunks.bag", 'w')
b.chunk_threshold = 0
b.write("/foo", String("2"), Time(2))
b.write("/foo", String("3"), Time(3))
b.write("/foo", String("1"), Time(1))
b.close()

Double checking created bag (note rosbag doesn't show proper duration either):

$ rosbag info example-unsorted-chunks.bag
path:        example-unsorted-chunks.bag
version:     2.0
duration:    -1.0s
start:       Jan 01 1970 00:00:02.00 (2.00)
end:         Jan 01 1970 00:00:01.00 (1.00)
size:        5.2 KB
messages:    3
compression: none [3/3 chunks]
types:       std_msgs/String [992ce8a1687cec8c8bd883ec73ca41d1]
topics:      /foo   3 msgs    : std_msgs/String

Test Plan

  • Added a new test to cover this
  • yarn run test

Copy link
Contributor

@MatthewSteel MatthewSteel left a comment

Choose a reason for hiding this comment

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

Yikes. Thanks for the link to the ros_comm discussion.

Seems possible that some "get messages" calls won't return time-ordered messages when this happens, but this seems like a good improvement anyway: cheap, short, and captures most of the upside -- with the wrong start/end times users might not see some messages at all, which is a lot worse than seeing messages in the wrong order.

@pankdm
Copy link
Contributor Author

pankdm commented Jun 22, 2022

Yep, exactly! Let's do this small incremental improvement first and then we can follow up on the ordering if needed.

@pankdm pankdm merged commit 8d295a0 into master Jun 22, 2022
Stuk pushed a commit that referenced this pull request Apr 5, 2023
* Fix startTime and endTime computation when chunks are not sorted

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

Successfully merging this pull request may close these issues.

2 participants