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

Fixes buoyancy flakiness when spawning entities #1808

Merged
merged 3 commits into from
Nov 23, 2022

Conversation

arjo129
Copy link
Contributor

@arjo129 arjo129 commented Nov 22, 2022

🦟 Bug fix

Fixes #

Summary

For reference see osrf/lrauv#272 (comment)

Essentially, if we spawn an entity using the UserCommand system, it will create the entity during the PreUpdate phase. However, the Buoyancy system only checks for new entities during the PreUpdate phase (It does this to precompute volume so it does not need to be computed on every run). This means the buoyancy system may or may not catch the newly created entities. This PR fixes this by checking for new entities both in the PreUpdate (for static entities) and the PostUpdate. One caveet is that we may end up running the volume calculations twice if the entities are found during the PreUpdate. However, if we don't check during the PreUpdate entities spawned when the world starts will experience a gravitational pull for one time step leading to a slow sinking behaviour.

I probably should back-port this.

Signed-off-by: Arjo Chakravarty arjo@openrobotics.org

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

For reference see osrf/lrauv#272 (comment)

Essentially, if we spawn an entity using the `UserCommand` system, it will create the entity during the `PreUpdate` phase. However, the `Buoyancy` system only checks for new entities during the `PreUpdate` phase (It does this to precompute volume so it does not need to be computed on every run). This means the buoyancy system may or may not catch the newly created entities.

Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
@github-actions github-actions bot added the 🌱 garden Ignition Garden label Nov 22, 2022
@arjo129 arjo129 added the bug Something isn't working label Nov 22, 2022
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
@codecov
Copy link

codecov bot commented Nov 23, 2022

Codecov Report

Merging #1808 (bc5dc53) into gz-sim7 (4fa1f26) will increase coverage by 0.04%.
The diff coverage is 84.88%.

@@             Coverage Diff             @@
##           gz-sim7    #1808      +/-   ##
===========================================
+ Coverage    64.37%   64.42%   +0.04%     
===========================================
  Files          341      341              
  Lines        27132    27151      +19     
===========================================
+ Hits         17467    17492      +25     
+ Misses        9665     9659       -6     
Impacted Files Coverage Δ
src/systems/buoyancy/Buoyancy.hh 100.00% <ø> (ø)
src/systems/buoyancy/Buoyancy.cc 82.25% <84.88%> (+1.59%) ⬆️
src/SimulationRunner.cc 92.27% <0.00%> (+0.94%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@arjo129
Copy link
Contributor Author

arjo129 commented Nov 23, 2022

Test Failures Unrelated.

Copy link
Contributor

@hidmic hidmic left a comment

Choose a reason for hiding this comment

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

LGTM

src/systems/buoyancy/Buoyancy.cc Outdated Show resolved Hide resolved
src/systems/buoyancy/Buoyancy.cc Outdated Show resolved Hide resolved
src/systems/buoyancy/Buoyancy.cc Outdated Show resolved Hide resolved
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
@arjo129 arjo129 merged commit e5c3ee9 into gz-sim7 Nov 23, 2022
@arjo129 arjo129 deleted the arjo/fix/buoyancy_check_for_new_items branch November 23, 2022 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🌱 garden Ignition Garden
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants