I'm trying to modify the name of a MuJoCo dm_control RootElement created from an XML file via the from_path
function:
from dm_control import mjcf
...
self.model = mjcf.from_path(path_to_xml_model)
...
With the XML file having a content like this:
<mujoco model="Animat">...</mujoco>
Once the model is created, I add it to my world (arena) by attaching it to a site:
def spawn_entity(self, entity, pos, angle):
spawn_site = self.root_element.worldbody.add('site', pos=pos, euler=angle)
spawn_site.attach(entity).add('freejoint')
with self.model
given as entity.
My problem is that I want to spawn multiple entities from the same model. MuJoCo handles it by creating the first one with geoms and joints named "Animat/..." and the other have a number attached, like "Animat_1/...", "Animat_2/...", etc... However, this is not practical for me, and I would like to be able to rename those model at creation, so I can then find the geoms and joints named as "MyFirstModelName/...", "MySecondModelName/...". Any idea how I can proceed?
Well, I do feel silly now that I found the solution: I was so focused on finding a property called "name" that I totally overlooked the property "model". The answer is thus very simple:
I'd still would have loved to find that without having to go through all the parser code from dm_control...