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

Added tests for the AnimationTime component #433

Merged
merged 2 commits into from
Nov 2, 2020

Conversation

adlarkin
Copy link
Contributor

I added missing tests for a std::chrono::steady_clock::duration component after doing something similar in #401.

Signed-off-by: Ashton Larkin [email protected]

@adlarkin adlarkin requested a review from chapulina as a code owner October 29, 2020 17:00
@github-actions github-actions bot added the 🔮 dome Ignition Dome label Oct 29, 2020
@adlarkin
Copy link
Contributor Author

adlarkin commented Oct 29, 2020

A few other things to consider:

  1. Should we use uint64_t instead of int64_t for de-serialization (relevant code snippet below), or can std::chrono::duration::count() return a negative value if a jump back in time occurs? (if negative count() return values are possible, I'll update Logical audio sensor plugin #401 to use int64_t)

https://github.com/ignitionrobotics/ign-gazebo/blob/aea1accff6d8daee0358ae9025e2a9797d292844/include/ignition/gazebo/components/Actor.hh#L58-L71

  1. The serialization/de-serialization methods are only as accurate as milliseconds, since that is what we are currently casting the durations to. If we want to serialize time that is more precise than milliseconds, then the information that exceeds millisecond precision will be lost. Should we use a more precise duration cast? For example, something like std::chrono::nanoseconds?

@codecov
Copy link

codecov bot commented Oct 29, 2020

Codecov Report

❗ No coverage uploaded for pull request base (ign-gazebo4@6f32258). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@              Coverage Diff               @@
##             ign-gazebo4     #433   +/-   ##
==============================================
  Coverage               ?   77.26%           
==============================================
  Files                  ?      208           
  Lines                  ?    11192           
  Branches               ?        0           
==============================================
  Hits                   ?     8648           
  Misses                 ?     2544           
  Partials               ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6f32258...02ad2db. Read the comment docs.

@chapulina
Copy link
Contributor

can std::chrono::duration::count() return a negative value if a jump back in time occurs?

The specific duration type we're using is std::chrono::steady_clock::duration, which is equivalent to std::chrono::nanoseconds, which under the hood is std::chrono::duration<int64_t, std::nano>. Note the int64_t there. So it can be negative.

You're right that we use negative durations for jumps back in time. For example, dt will be negative when a log playback is rewinded:

https://github.com/ignitionrobotics/ign-gazebo/blob/da2ddbc14bc487d53e49de5b9fdea3272797698c/src/systems/log/LogPlayback.cc#L484-L486

Now, will it ever be negative for AnimationTime? I don't think it should. But I was trying to be general when implementing the serialization.

Should we use a more precise duration cast?

Yeah I think that's a good idea. For the animation it probably isn't necessary, but I think it's good to be general.

@adlarkin
Copy link
Contributor Author

adlarkin commented Nov 2, 2020

I went ahead and modified the serialization to use nanoseconds instead of milliseconds in 02ad2db. This should be ready for another review now.

@adlarkin adlarkin mentioned this pull request Nov 2, 2020
3 tasks
Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

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

Nice, thanks for the test!

@chapulina chapulina merged commit 020a017 into ign-gazebo4 Nov 2, 2020
@chapulina chapulina deleted the adlarkin/actor_component_tests branch November 2, 2020 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔮 dome Ignition Dome
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants