Closed marioprats closed 2 months ago
Hmmm, this should work. (That said, there is no test for this function, so ya this could be a bug)
@saran-t is there a bug in this line?
It's certainly not deep-copying the arena. I can't remember whether that was a deliberate choice though, for MJPC?
Oh damn you're right. So the comment // copy arena memory
is basically a lie eh?
It should either be // set arena pointers, don't copy memory
or we should actually copy the memory...
I have no recollection of this being a deliberate choice, seems like a strange thing to do. @nimrod-gileadi, @erez-tom, @thowell, any such recollection?
Marking this as a bug, even if we end up deciding that it's deliberate, the inline and API docs should be updated.
We do have tests for this function in the Python bindings, but indeed we don't check for contacts: https://github.com/google-deepmind/mujoco/blob/14a3ce5ffac0550a645ca391119014f489f70b55/python/mujoco/bindings_test.py#L430
I think that copying the arena content is the right thing to do. Can't see why not.
Hi, I have an issue with
mj_copyData
not copying contact details. Not sure if this is a bug or something intended.Here is a minimal model:
minimal XML
```XMLIt has a sphere in contact with a ground plane. I found the issue with
mj_copyData
in C++, but it can be reproduced in python too:minimal Python reproduction case
```python import mujoco import copy model = mujoco.MjModel.from_xml_path("scene.xml") data = mujoco.MjData(model) mujoco.mj_forward(model,data) print("Original data:") print(" n_contacts: ", data.ncon) print(" colliding geoms: ", data.contact.geom) data2 = copy.copy(data) print("Data copy:") print(" n_contacts: ", data2.ncon) print(" colliding geoms: ", data2.contact.geom) ```The output is:
So the copy preserves
ncon
, but doesn't seem to copy contact details over (e.g. colliding geoms).