-
Notifications
You must be signed in to change notification settings - Fork 819
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
Dynamically Update Assets (height field) #958
Labels
question
Request for help or information
Comments
This cannot work since the viewer is completely separate from the Python process. |
I see. An ugly workaround for now is to close the existing viewer and re-open a new viewer (which picks up the new updaes) from mujoco import viewer
from dm_control.mujoco import Physics
from dm_control.mujoco.wrapper.mjbindings import mjlib
import numpy as np
# Prepare physics
sim = Physics.from_xml_path('height_field.xml')
# Prepare viewer
window = viewer.launch_passive(sim.model.ptr, sim.data.ptr)
# New height field
for _ in range(5):
# wait for user request =
input("Press enter to request new height field")
window.close()
# Prep new hfield
sim.model.hfield_data[:] = np.random.uniform(high=.2, low=.1, size=np.shape(sim.model.hfield_data))
window = viewer.launch_passive(sim.model.ptr, sim.data.ptr)
# Sync viewer
window.sync()
``` |
I'll keep thinking about alternative solutions. |
This is amazing! Thanks @saran-t |
This is now available in version 2.3.7 which was just released. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to dynamically update assets. While the model is getting updated and the simulation reflects the update, the viewer is not appropriately reflecting the update despite these updates being pushed to the mjr_contexts. Likely I'm missing something. Im attaching a simple script to reproduce.
mujoco==2.3.5
dm-control==1.0.11
os = Ubuntu 18.04.6 LTS
Python 3.8.16
asset_update.zip
cc: @cameronberg
The text was updated successfully, but these errors were encountered: