def create_scene(self, mj_robots, mj_surrounding, object_list: list, dt):
if object_list is None:
object_list = []
if not isinstance(object_list, list):
object_list = [object_list]
# Build a single list so we can iterate multiple times
all_objects = chain([mj_surrounding], object_list, mj_robots)
all_objects = [obj for obj in all_objects]
for obj in all_objects:
self.load_mj_loadable(obj)
self.set_dt(dt)
model = mujoco.MjModel.from_xml_string(self.mj_xml_string, self.assets)
data = mujoco.MjData(model)
# all_objects is a real list now, not an exhausted iterator
self.cleanup(all_objects)
return model, data
In
MjSceneParser.create_scene, theall_objectsvariable is aitertools.chainobject which is exhausted after the first iteration. This meansself.cleanup(all_objects)always receives an empty iterator. This results in a new temporary robot xml file being created underd3il_sim/model/mj/robots/each time an environment is instantiated. Below is a proposed fix.