def generate_xml_dict()

in mujoco_worldgen/objs/obj_from_xml.py [0:0]


    def generate_xml_dict(self):
        '''
        Generate XML DOM nodes needed for MuJoCo model.
            doc - XML Document, used to create elements/nodes
            name_indexes - dictionary to keep track of names,
                see get_name_index() for internals
        Returns a dictionary with keys as names of top-level nodes:
            e.g. 'worldbody', 'materials', 'assets'
        And the values are lists of XML DOM nodes
        '''
        # Iterate over all names inside and prepend self.name
        recursive_rename(self.xml, self.name)
        main_body = None
        worldbody = self.xml["worldbody"]
        bodies = worldbody["body"]
        for body in bodies:
            name = body.get('@name', '')  # Might not be present in main body
            if "annotation" not in name and not body.get('@mocap'):
                assert main_body is None, "We support only a single main body."
                main_body = body
        for rot in ('@euler', '@quat'):
            assert rot not in main_body, 'We dont support rotations in the main body.'\
                                         'Please move it inward.'
        self.add_joints(main_body)
        return self.xml