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

remove messages that are newer than the newly added message #1438

Merged
merged 7 commits into from
Jan 31, 2019

Conversation

christian-rauch
Copy link
Contributor

In some circumstances, when replaying a log in loop mode (-l) the synchronisation blocks because messages jump back in time when restarting the log. This commit removes messages that are newer than the newly added message, enabling to synchronise looped log files. This could optionally enabled via a parameter that gives the maximum tolerated backward jump in time.

Copy link
Member

@tfoote tfoote left a comment

Choose a reason for hiding this comment

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

Logic to clear the filter when looping bag playback might make sense but I don't think that this is the right approach. It assumes all messages arrive in order except for a loop which is not guarenteed. There could easily be multiple publishers and publishers with higher latency.

There is logic in tf2_ros to reset it's buffers if the clock jumps backwards. I would suggest looking at that sort of logic as that is much more clearly a time discontinuity and behavior should change. Rather than possibly a delayed message arriving into a synchronizer.

@christian-rauch
Copy link
Contributor Author

I agree that /clock is a more sensible reference for the time than the timestamped messages. I implemented the buffer clearing logic like in ros/geometry2#68 (I think this is the logic you were referring to).

@tfoote
Copy link
Member

tfoote commented Jun 20, 2018

That looks better to me. Two comments though.

With the additional use of now() the mock initialization of the time in the test needs to be moved earlier.

And the logic should provide a warning about the reset. Otherwise this could be triggered regularly and all data would potentially be silently dropped.

@christian-rauch
Copy link
Contributor Author

The message about the reset is printed as info, not as warning. From my point of view, clearing the buffer on jumps backward in time is an expected behaviour while the alternative of blocking the synchronisation (by not clearing the buffers) is unexpected.

@tfoote
Copy link
Member

tfoote commented Jun 20, 2018

info output is fine too. It looks like this is being triggered in the current tests and causing a failure. And related to that we should add a unit test to explicitly test that this is working and won't regress in the future.

@christian-rauch
Copy link
Contributor Author

The test fails because it not only scrambles the sequence of messages, but also the clock time that is supposed to be continuous: rospy.rostime._set_rostime(rospy.Time(i+0.05)) where i is randomly sampled. Given that we assume that clock time is continuous (but header stamps can be unordered), does this test of synchronising header-less messages sense? I.e. by definition, messages without header do not have an order.

@christian-rauch
Copy link
Contributor Author

@tfoote Does this look all right to you now?

@dirk-thomas
Copy link
Member

@ros-pull-request-builder retest this please

@dirk-thomas
Copy link
Member

The C++ equivalent will likely only be part of the next ROS distro (see #1518 (comment)) I am not sure if you still want to wait with this patch to release them in sync or merge this into Melodic now?

@christian-rauch
Copy link
Contributor Author

We can merge this now. Then at least people which are using the python interface will benefit from this.

@dirk-thomas
Copy link
Member

Sounds good to me. Thanks for the patch.

@dirk-thomas dirk-thomas merged commit 1bfa1dc into ros:melodic-devel Jan 31, 2019
@christian-rauch christian-rauch deleted the patch-1 branch January 31, 2019 23:59
tahsinkose pushed a commit to tahsinkose/ros_comm that referenced this pull request Apr 15, 2019
* remove messages that are newer than the newly added message

* use /clock as reference for detecting backward jumps

* set time to initialised after constructing ApproximateTimeSynchronizer

* notify user about clearing buffer

* use continuous time for testing header-less message synchronisation

* test buffer clearing when jumping back in time

* avoid unrelated changes, remove double space
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants