-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Branch: main (9febd76)
I am adding a geom to the existing model and runningrecompile(model, data) to obtain the updated model. However, the updates are not being applied in-place contrary to the documentation https://mujoco.readthedocs.io/en/latest/APIreference/APIfunctions.html#mj-recompile. This issue is also mentioned in #1822, which was closed without any comment.
Code to reproduce:
import mujoco as mj
# Define a simple model
model_string = """
<mujoco>
<worldbody>
<body>
<freejoint/>
<geom size=".15" mass="1" type="sphere"/>
</body>
</worldbody>
</mujoco>
"""
# Compile the model
spec = mj.MjSpec()
spec.from_string(model_string)
model = spec.compile()
data = mj.MjData(model)
# Add a geom to the world body
body = spec.worldbody
geom = body.add_geom()
geom.name = 'my_geom'
geom.size[0] = 1
geom.pos = [1, 1, 0]
# Recompile the model
new_model, new_data = spec.recompile(model, data)
new_model.geom('my_geom') # No error
model.geom('my_geom')
Error:
# KeyError: "Invalid name 'my_geom'. Valid names: []"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working