(self, filename)
Helper method for handling setup of the MuJoCo world.
        Args:
            filename: Path to XML file containing the world information.
Helper method for handling setup of the MuJoCo world.
        Args:
            filename: Path to XML file containing the world information.
Helper method for handling setup of the MuJoCo world . Args : filename : Path to XML file containing the world information .
def _setup_world(self, filename):
        """
        Helper method for handling setup of the MuJoCo world.
        Args:
            filename: Path to XML file containing the world information.
        """
        self._world = []
        self._model = []

        # Initialize Mujoco worlds. If there's only one xml file, create a single world object,
        # otherwise create a different world for each condition.
        if not isinstance(filename, list):
            world = mjcpy.MJCWorld(filename)
            self._world = [world for _ in range(self._hyperparams['conditions'])]
            self._model = [self._world[i].get_model().copy()
                           for i in range(self._hyperparams['conditions'])]
        else:
            for i in range(self._hyperparams['conditions']):
                self._world.append(mjcpy.MJCWorld(self._hyperparams['filename'][i]))
                self._model.append(self._world[i].get_model())

        for i in range(self._hyperparams['conditions']):
            for j in range(len(self._hyperparams['pos_body_idx'][i])):
                idx = self._hyperparams['pos_body_idx'][i][j]
                self._model[i]['body_pos'][idx, :] += \
                        self._hyperparams['pos_body_offset'][i][j]

        self._joint_idx = list(range(self._model[0]['nq']))
        self._vel_idx = [i + self._model[0]['nq'] for i in self._joint_idx]

        # Initialize x0.
        self.x0 = []
        for i in range(self._hyperparams['conditions']):
            if END_EFFECTOR_POINTS in self.x_data_types:
                # TODO: this assumes END_EFFECTOR_VELOCITIES is also in datapoints right?
                self._init(i)
                eepts = self._world[i].get_data()['site_xpos'].flatten()
                self.x0.append(
                    np.concatenate([self._hyperparams['x0'][i], eepts, np.zeros_like(eepts)])
                )
            elif END_EFFECTOR_POINTS_NO_TARGET in self.x_data_types:
                self._init(i)
                eepts = self._world[i].get_data()['site_xpos'].flatten()
                eepts_notgt = np.delete(eepts, self._hyperparams['target_idx'])
                self.x0.append(
                    np.concatenate([self._hyperparams['x0'][i], eepts_notgt, np.zeros_like(eepts_notgt)])
                )
            else:
                self.x0.append(self._hyperparams['x0'][i])
            if IMAGE_FEAT in self.x_data_types:
                self.x0[i] = np.concatenate([self.x0[i], np.zeros((self._hyperparams['sensor_dims'][IMAGE_FEAT],))])

        cam_pos = self._hyperparams['camera_pos']
        for i in range(self._hyperparams['conditions']):
            self._world[i].init_viewer(AGENT_MUJOCO['image_width'],
                                       AGENT_MUJOCO['image_height'],
                                       cam_pos[0], cam_pos[1], cam_pos[2],
                                       cam_pos[3], cam_pos[4], cam_pos[5])
def _setup_world ( self , filename ) : self . _world = [ ] self . _model = [ ] # Initialize Mujoco worlds. If there's only one xml file, create a single world object, # otherwise create a different world for each condition. if not isinstance ( filename , list ) : world = mjcpy . MJCWorld ( filename ) self . _world = [ world for _ in range ( self . _hyperparams [ 'conditions' ] ) ] self . _model = [ self . _world [ i ] . get_model ( ) . copy ( ) for i in range ( self . _hyperparams [ 'conditions' ] ) ] else : for i in range ( self . _hyperparams [ 'conditions' ] ) : self . _world . append ( mjcpy . MJCWorld ( self . _hyperparams [ 'filename' ] [ i ] ) ) self . _model . append ( self . _world [ i ] . get_model ( ) ) for i in range ( self . _hyperparams [ 'conditions' ] ) : for j in range ( len ( self . _hyperparams [ 'pos_body_idx' ] [ i ] ) ) : idx = self . _hyperparams [ 'pos_body_idx' ] [ i ] [ j ] self . _model [ i ] [ 'body_pos' ] [ idx , : ] += self . _hyperparams [ 'pos_body_offset' ] [ i ] [ j ] self . _joint_idx = list ( range ( self . _model [ 0 ] [ 'nq' ] ) ) self . _vel_idx = [ i + self . _model [ 0 ] [ 'nq' ] for i in self . _joint_idx ] # Initialize x0. self . x0 = [ ] for i in range ( self . _hyperparams [ 'conditions' ] ) : if END_EFFECTOR_POINTS in self . x_data_types : # TODO: this assumes END_EFFECTOR_VELOCITIES is also in datapoints right? self . _init ( i ) eepts = self . _world [ i ] . get_data ( ) [ 'site_xpos' ] . flatten ( ) self . x0 . append ( np . concatenate ( [ self . _hyperparams [ 'x0' ] [ i ] , eepts , np . zeros_like ( eepts ) ] ) ) elif END_EFFECTOR_POINTS_NO_TARGET in self . x_data_types : self . _init ( i ) eepts = self . _world [ i ] . get_data ( ) [ 'site_xpos' ] . flatten ( ) eepts_notgt = np . delete ( eepts , self . _hyperparams [ 'target_idx' ] ) self . x0 . append ( np . concatenate ( [ self . _hyperparams [ 'x0' ] [ i ] , eepts_notgt , np . zeros_like ( eepts_notgt ) ] ) ) else : self . x0 . append ( self . _hyperparams [ 'x0' ] [ i ] ) if IMAGE_FEAT in self . x_data_types : self . x0 [ i ] = np . concatenate ( [ self . x0 [ i ] , np . zeros ( ( self . _hyperparams [ 'sensor_dims' ] [ IMAGE_FEAT ] , ) ) ] ) cam_pos = self . _hyperparams [ 'camera_pos' ] for i in range ( self . _hyperparams [ 'conditions' ] ) : self . _world [ i ] . init_viewer ( AGENT_MUJOCO [ 'image_width' ] , AGENT_MUJOCO [ 'image_height' ] , cam_pos [ 0 ] , cam_pos [ 1 ] , cam_pos [ 2 ] , cam_pos [ 3 ] , cam_pos [ 4 ] , cam_pos [ 5 ] )