Fix Buoyancy state contamination on world reset#3520
Open
XINJIANGMO wants to merge 10 commits intogazebosim:mainfrom
Open
Fix Buoyancy state contamination on world reset#3520XINJIANGMO wants to merge 10 commits intogazebosim:mainfrom
XINJIANGMO wants to merge 10 commits intogazebosim:mainfrom
Conversation
Signed-off-by: momo <2438833481@qq.com>
Signed-off-by: momo <2438833481@qq.com>
Signed-off-by: momo <2438833481@qq.com>
Signed-off-by: momo <2438833481@qq.com>
Signed-off-by: momo <2438833481@qq.com>
Signed-off-by: momo <2438833481@qq.com>
Signed-off-by: momo <2438833481@qq.com>
Signed-off-by: momo <2438833481@qq.com>
Signed-off-by: momo <2438833481@qq.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a world-reset bug in the Buoyancy system where cached per-link state (and missing runtime components) could survive across resets, causing post-reset motion to diverge from the initial “early-episode” trajectory.
Changes:
- Implement
ISystemResetinBuoyancyto clear cached state and trigger a one-time full entity rescan after reset. - Update entity scanning logic to optionally use a full
Eachpass (instead ofEachNew) immediately after reset. - Add an integration test that records model pose trajectories before/after reset in
graded_buoyancy.sdfand asserts they match within tolerance.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/integration/buoyancy.cc | Adds a reset regression test validating trajectory equivalence pre/post reset. |
| src/systems/buoyancy/Buoyancy.hh | Extends the system interfaces to include ISystemReset and declares Reset. |
| src/systems/buoyancy/Buoyancy.cc | Clears cached data on reset and performs a one-time full link scan to rebuild runtime components. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🦟 Bug fix
Depends on #3503
Summary
During the reset audit, the
Buoyancyplugin failed the tests. After an environment reset, the model didn’t consistently return to its early-episode trajectory.Test logic
graded_buoyancy.sdfbefore resetting.Root cause
The issue stems from how
Buoyancytracks the running state of links. It originally relied on theEachNewentity scan to fetch and cache components likeVolumeandCenterOfVolume. When the world resets, the entities are restored but they aren't strictly considered "new" again by theECM. This led to broken buoyancy states where required components couldn't be reliably rebuilt on reset.Fix logic
BuoyancycenterOfVolumes,volumesandbuoyancyForcesrescanEntitiesflag. Once a reset occurs, this flag triggers a fresh, full entity component scan in the very nextPreUpdatestep, gracefully recovering the required runtime components.Checklist
codecheckpassed (See contributing)Generated-by: Remove this if GenAI was not used.
Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-byandGenerated-bymessages.Backports: If this is a backport, please use Rebase and Merge instead.