Beispiel #1
0
    def copy(self, share_model=False):
        """Creates a copy of this `Physics` instance.

    Args:
      share_model: If True, the copy and the original will share a common
        MjModel instance. By default, both model and data will both be copied.

    Returns:
      A `Physics` instance.
    """
        if not share_model:
            new_model = self.model.copy()
        else:
            new_model = self.model
        new_data = wrapper.MjData(new_model)
        mjlib.mj_copyData(new_data.ptr, new_data.model.ptr, self.data.ptr)
        cls = self.__class__
        new_obj = cls.__new__(cls)
        new_obj._reload_from_data(new_data)  # pylint: disable=protected-access
        return new_obj
Beispiel #2
0
 def __copy__(self):
   # This makes a shallow copy that shares the same parent MjModel instance.
   new_obj = self.__class__(self.model)
   mjlib.mj_copyData(new_obj.ptr, self.model.ptr, self.ptr)
   return new_obj
Beispiel #3
0
 def deepcopy(self):
     """Returns a copy of this MjData instance with a new MjModel."""
     new_obj = self.__class__(self.model.copy())
     mjlib.mj_copyData(new_obj.ptr, self.model.ptr, self.ptr)
     return new_obj