(self, sample, mj_X, t, condition, feature_fn=None)
Set the data for a sample for one time step.
        Args:
            sample: Sample object to set data for.
            mj_X: Data to set for sample.
            t: Time step to set for sample.
            condition: Which condition to set.
            feature_fn: function to compute image features from the observation.
Set the data for a sample for one time step.
        Args:
            sample: Sample object to set data for.
            mj_X: Data to set for sample.
            t: Time step to set for sample.
            condition: Which condition to set.
            feature_fn: function to compute image features from the observation.
Set the data for a sample for one time step . Args : sample : Sample object to set data for . mj_X : Data to set for sample . t : Time step to set for sample . condition : Which condition to set . feature_fn : function to compute image features from the observation .
def _set_sample(self, sample, mj_X, t, condition, feature_fn=None):
        """
        Set the data for a sample for one time step.
        Args:
            sample: Sample object to set data for.
            mj_X: Data to set for sample.
            t: Time step to set for sample.
            condition: Which condition to set.
            feature_fn: function to compute image features from the observation.
        """
        sample.set(JOINT_ANGLES, np.array(mj_X[self._joint_idx]), t=t+1)
        sample.set(JOINT_VELOCITIES, np.array(mj_X[self._vel_idx]), t=t+1)
        cur_eepts = self._data['site_xpos'].flatten()
        sample.set(END_EFFECTOR_POINTS, cur_eepts, t=t+1)
        prev_eepts = sample.get(END_EFFECTOR_POINTS, t=t)
        eept_vels = (cur_eepts - prev_eepts) / self._hyperparams['dt']
        sample.set(END_EFFECTOR_POINT_VELOCITIES, eept_vels, t=t+1)

        if (END_EFFECTOR_POINTS_NO_TARGET in self._hyperparams['obs_include']):
            sample.set(END_EFFECTOR_POINTS_NO_TARGET, np.delete(cur_eepts, self._hyperparams['target_idx']), t=t+1)
            sample.set(END_EFFECTOR_POINT_VELOCITIES_NO_TARGET, np.delete(eept_vels, self._hyperparams['target_idx']), t=t+1)

        jac = np.zeros([cur_eepts.shape[0], self._model[condition]['nq']])
        for site in range(cur_eepts.shape[0] // 3):
            idx = site * 3
            jac[idx:(idx+3), :] = self._world[condition].get_jac_site(site)
        sample.set(END_EFFECTOR_POINT_JACOBIANS, jac, t=t+1)
        if RGB_IMAGE in self.obs_data_types:
            img = self._world[condition].get_image_scaled(self._hyperparams['image_width'],
                                                          self._hyperparams['image_height'])
            sample.set(RGB_IMAGE, np.transpose(img["img"], (2, 1, 0)).flatten(), t=t+1)
            if feature_fn is not None:
                obs = sample.get_obs()  # Assumes that the rest of the observation has been populated
                sample.set(IMAGE_FEAT, feature_fn(obs), t=t+1)
            else:
                # TODO - need better solution than setting this to 0.
                sample.set(IMAGE_FEAT, np.zeros((self._hyperparams['sensor_dims'][IMAGE_FEAT],)), t=t+1)
def _set_sample ( self , sample , mj_X , t , condition , feature_fn = None ) : sample . set ( JOINT_ANGLES , np . array ( mj_X [ self . _joint_idx ] ) , t = t + 1 ) sample . set ( JOINT_VELOCITIES , np . array ( mj_X [ self . _vel_idx ] ) , t = t + 1 ) cur_eepts = self . _data [ 'site_xpos' ] . flatten ( ) sample . set ( END_EFFECTOR_POINTS , cur_eepts , t = t + 1 ) prev_eepts = sample . get ( END_EFFECTOR_POINTS , t = t ) eept_vels = ( cur_eepts - prev_eepts ) / self . _hyperparams [ 'dt' ] sample . set ( END_EFFECTOR_POINT_VELOCITIES , eept_vels , t = t + 1 ) if ( END_EFFECTOR_POINTS_NO_TARGET in self . _hyperparams [ 'obs_include' ] ) : sample . set ( END_EFFECTOR_POINTS_NO_TARGET , np . delete ( cur_eepts , self . _hyperparams [ 'target_idx' ] ) , t = t + 1 ) sample . set ( END_EFFECTOR_POINT_VELOCITIES_NO_TARGET , np . delete ( eept_vels , self . _hyperparams [ 'target_idx' ] ) , t = t + 1 ) jac = np . zeros ( [ cur_eepts . shape [ 0 ] , self . _model [ condition ] [ 'nq' ] ] ) for site in range ( cur_eepts . shape [ 0 ] // 3 ) : idx = site * 3 jac [ idx : ( idx + 3 ) , : ] = self . _world [ condition ] . get_jac_site ( site ) sample . set ( END_EFFECTOR_POINT_JACOBIANS , jac , t = t + 1 ) if RGB_IMAGE in self . obs_data_types : img = self . _world [ condition ] . get_image_scaled ( self . _hyperparams [ 'image_width' ] , self . _hyperparams [ 'image_height' ] ) sample . set ( RGB_IMAGE , np . transpose ( img [ "img" ] , ( 2 , 1 , 0 ) ) . flatten ( ) , t = t + 1 ) if feature_fn is not None : obs = sample . get_obs ( ) # Assumes that the rest of the observation has been populated sample . set ( IMAGE_FEAT , feature_fn ( obs ) , t = t + 1 ) else : # TODO - need better solution than setting this to 0. sample . set ( IMAGE_FEAT , np . zeros ( ( self . _hyperparams [ 'sensor_dims' ] [ IMAGE_FEAT ] , ) ) , t = t + 1 )