(self, data)
Initializes a new or existing `Physics` instance from a `wrapper.MjData`.

    Assigns all attributes, sets up named indexing, and creates rendering
    contexts if rendering is enabled.

    The default constructor as well as the other `reload_from` methods should
    delegate to this method.

    Args:
      data: Instance of `wrapper.MjData`.
Initializes a new or existing `Physics` instance from a `wrapper.MjData`.
Initializes a new or existing Physics instance from a wrapper . MjData .
def _reload_from_data(self, data):
    """Initializes a new or existing `Physics` instance from a `wrapper.MjData`.

    Assigns all attributes, sets up named indexing, and creates rendering
    contexts if rendering is enabled.

    The default constructor as well as the other `reload_from` methods should
    delegate to this method.

    Args:
      data: Instance of `wrapper.MjData`.
    """
    self._data = data

    # Performance optimization: pre-allocate numpy arrays used when checking for
    # MuJoCo warnings on each step.
    self._warnings = self.data.warning.number
    self._warnings_before = np.empty_like(self._warnings)
    self._new_warnings = np.empty(dtype=bool, shape=self._warnings.shape)

    # Forcibly free any previous GL context in order to avoid problems with GL
    # implementations that do not support multiple contexts on a given device.
    with self._contexts_lock:
      if self._contexts:
        self._free_rendering_contexts()

    # Call kinematics update to enable rendering.
    try:
      self.after_reset()
    except _control.PhysicsError as e:
      logging.warning(e)

    # Set up named indexing.
    axis_indexers = index.make_axis_indexers(self.model)
    self._named = NamedIndexStructs(
        model=index.struct_indexer(self.model, 'mjmodel', axis_indexers),
        data=index.struct_indexer(self.data, 'mjdata', axis_indexers),)
def _reload_from_data ( self , data ) : self . _data = data # Performance optimization: pre-allocate numpy arrays used when checking for # MuJoCo warnings on each step. self . _warnings = self . data . warning . number self . _warnings_before = np . empty_like ( self . _warnings ) self . _new_warnings = np . empty ( dtype = bool , shape = self . _warnings . shape ) # Forcibly free any previous GL context in order to avoid problems with GL # implementations that do not support multiple contexts on a given device. with self . _contexts_lock : if self . _contexts : self . _free_rendering_contexts ( ) # Call kinematics update to enable rendering. try : self . after_reset ( ) except _control . PhysicsError as e : logging . warning ( e ) # Set up named indexing. axis_indexers = index . make_axis_indexers ( self . model ) self . _named = NamedIndexStructs ( model = index . struct_indexer ( self . model , 'mjmodel' , axis_indexers ) , data = index . struct_indexer ( self . data , 'mjdata' , axis_indexers ) , )