fix: rebind domain randomization modders after a hard reset#818
Open
VihaanAgarwal wants to merge 1 commit into
Open
fix: rebind domain randomization modders after a hard reset#818VihaanAgarwal wants to merge 1 commit into
VihaanAgarwal wants to merge 1 commit into
Conversation
A hard reset frees the old MjSim and builds a new one, but the wrapper saved the default domain before pointing its modders at the new sim. On the "mujoco" renderer the modders still referenced the freed sim, so the next reset raised "'MjSim' object has no attribute 'model'". Move the update_sim call ahead of save_default_domain so the modders read from the live sim, and add a regression test that resets a wrapped env across several hard resets. Fixes ARISE-Initiative#426
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.
What this does
Fixes #426 (🐛 Bug)
When an environment uses the
mujocorenderer, a hard reset frees the oldMjSimand builds a new one (_destroy_simthen_initialize_siminMujocoEnv.reset).DomainRandomizationWrapper.resetcalledsave_default_domain()before rebinding its modders to the new sim, so the modders still pointed at the freed sim. Reading a model parameter from it then raised:Reproducer from the issue:
The
update_simloop that rebinds the modders already existed, it just ran aftersave_default_domain(). Moving it ahead of the save so the modders read from the live sim is enough to fix it. This is also what was suggested in the issue thread.How it was tested
Added
test_domain_randomization_hard_resetintests/test_environments/test_domain_randomization.py. It wraps aLiftenv with themujocorenderer and resets it across several hard resets. The test fails onmasterwith theAttributeErrorabove and passes with this change.randomize_coloris left off in the test becauseTextureModderrequiresmujoco==3.1.1.black,isortandflake8are clean on the changed files.How to checkout & try? (for the reviewer)