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

Support world reset #1249

Merged
merged 8 commits into from
Mar 22, 2022
Merged

Support world reset #1249

merged 8 commits into from
Mar 22, 2022

Conversation

azeey
Copy link
Contributor

@azeey azeey commented Dec 14, 2021

🎉 New feature

Toward #1107

Summary

This adds a new phase in which systems can implement special Reset functionality. The approach taken is to make an initial copy of the ECM after the entities have been created. When reset is requested, a diff is computed between the current ECM and the initial copy. This is necessary to ensure that entities that were added later on are marked as removed after reset. Likewise, entities that were removed later on are marked as newly added after reset.

The physics system has been updated to make use of the Reset phase. The changes were nontrivial because we keep a lot of state in the physics system to help with performance. Hopefully, updating other systems will be more straightforward.

The Reset API allows systems to make changes to the ECM. This can be used to, for example, change the poses of objects in the scene at every reset without having to reload the the world. As an example, I have created a small and very trivial joint position randomizer.

There things that still need to be cleaned up and tests that need to be added, but I wanted open this as a draft PR to get feedback on the approach.

Test it

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • 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

@azeey azeey requested a review from mjcarroll December 14, 2021 17:11
@github-actions github-actions bot added the 🌱 garden Ignition Garden label Dec 14, 2021
@mjcarroll
Copy link
Contributor

This will be cleaner when we get #1340 landed and forward ported

mjcarroll and others added 4 commits March 8, 2022 14:30
Co-authored-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Co-authored-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
@codecov
Copy link

codecov bot commented Mar 15, 2022

Codecov Report

Merging #1249 (ec06268) into main (1e0041a) will increase coverage by 0.12%.
The diff coverage is 92.23%.

@@            Coverage Diff             @@
##             main    #1249      +/-   ##
==========================================
+ Coverage   62.22%   62.34%   +0.12%     
==========================================
  Files         316      317       +1     
  Lines       24317    24419     +102     
==========================================
+ Hits        15131    15224      +93     
- Misses       9186     9195       +9     
Impacted Files Coverage Δ
include/ignition/gazebo/EntityComponentManager.hh 100.00% <ø> (ø)
include/ignition/gazebo/System.hh 100.00% <ø> (ø)
include/ignition/gazebo/detail/BaseView.hh 100.00% <ø> (ø)
include/ignition/gazebo/detail/View.hh 97.89% <0.00%> (-2.11%) ⬇️
src/SimulationRunner.hh 100.00% <ø> (ø)
src/SystemManager.cc 98.36% <75.00%> (-1.64%) ⬇️
src/EntityComponentManagerDiff.cc 81.25% <81.25%> (ø)
src/SimulationRunner.cc 91.98% <88.88%> (-0.06%) ⬇️
src/EntityComponentManager.cc 89.17% <98.57%> (+0.80%) ⬆️
src/SystemInternal.hh 100.00% <100.00%> (ø)
... and 2 more

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 1e0041a...ec06268. Read the comment docs.

@mjcarroll
Copy link
Contributor

@osrf-jenkins retest this please

@mjcarroll mjcarroll merged commit 09462f5 into main Mar 22, 2022
@mjcarroll mjcarroll deleted the reset branch March 22, 2022 20:21
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.

I believe this PR broke compilation on Windows:

[1830.187s] EntityComponentManager_TEST.obj : error LNK2001: unresolved external symbol "public: void __cdecl ignition::gazebo::v7::EntityComponentManagerDiff::ClearRemovedEntities(void)" (?ClearRemovedEntities@EntityComponentManagerDiff@v7@gazebo@ignition@@QEAAXXZ) [C:\Jenkins\workspace\ign_gazebo-pr-win\ws\build\ignition-gazebo7\src\UNIT_EntityComponentManager_TEST.vcxproj]
[1830.187s] EntityComponentManager_TEST.obj : error LNK2001: unresolved external symbol "public: class std::vector<unsigned __int64,class std::allocator<unsigned __int64> > const & __cdecl ignition::gazebo::v7::EntityComponentManagerDiff::AddedEntities(void)const " (?AddedEntities@EntityComponentManagerDiff@v7@gazebo@ignition@@QEBAAEBV?$vector@_KV?$allocator@_K@std@@@std@@XZ) [C:\Jenkins\workspace\ign_gazebo-pr-win\ws\build\ignition-gazebo7\src\UNIT_EntityComponentManager_TEST.vcxproj]
[1830.187s] EntityComponentManager_TEST.obj : error LNK2001: unresolved external symbol "public: class std::vector<unsigned __int64,class std::allocator<unsigned __int64> > const & __cdecl ignition::gazebo::v7::EntityComponentManagerDiff::RemovedEntities(void)const " (?RemovedEntities@EntityComponentManagerDiff@v7@gazebo@ignition@@QEBAAEBV?$vector@_KV?$allocator@_K@std@@@std@@XZ) [C:\Jenkins\workspace\ign_gazebo-pr-win\ws\build\ignition-gazebo7\src\UNIT_EntityComponentManager_TEST.vcxproj]
[1830.187s] C:\Jenkins\workspace\ign_gazebo-pr-win\ws\build\ignition-gazebo7\bin\Release\UNIT_EntityComponentManager_TEST.exe : fatal error LNK1120: 3 unresolved externals [C:\Jenkins\workspace\ign_gazebo-pr-win\ws\build\ignition-gazebo7\src\UNIT_EntityComponentManager_TEST.vcxproj]

@azeey / @mjcarroll , can you take a look?

// Inline bracket to help doxygen filtering.
inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {

class EntityComponentManagerDiff
Copy link
Contributor

Choose a reason for hiding this comment

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

This class should be documented

@mjcarroll
Copy link
Contributor

I can take a look. Windows CI has been pretty flaky lately, so I merged without it.

@adlarkin adlarkin mentioned this pull request Apr 12, 2022
7 tasks
mjcarroll added a commit that referenced this pull request May 17, 2022
This builds upon the reset interface for systems introduced in #1249 by implementing the interface for the Physics system.

Upon receiving a reset command, this allows the physics plugin to rewind to the initial state of the world without removing and re-adding all of the entities.

Signed-off-by: Michael Carroll <[email protected]>
Co-authored-by: Addisu Z. Taddese <[email protected]>
Co-authored-by: Louise Poubel <[email protected]>
@j-rivero j-rivero mentioned this pull request Sep 16, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱 garden Ignition Garden
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants