(self, attachment)
return frame
Attaches another MJCF model at this site.

    An empty <body> will be created as an attachment frame. All children of
    `attachment`'s <worldbody> will be treated as children of this frame.
    Furthermore, all other elements in `attachment` are merged into the root
    of the MJCF model to which this element belongs.

    Args:
      attachment: An MJCF `RootElement`

    Returns:
      An `mjcf.Element` corresponding to the attachment frame. A joint can be
      added directly to this frame to give degrees of freedom to the attachment.

    Raises:
      ValueError: If `other` is not a valid attachment to this element.
Attaches another MJCF model at this site.
Attaches another MJCF model at this site .
def attach(self, attachment):
    """Attaches another MJCF model at this site.

    An empty <body> will be created as an attachment frame. All children of
    `attachment`'s <worldbody> will be treated as children of this frame.
    Furthermore, all other elements in `attachment` are merged into the root
    of the MJCF model to which this element belongs.

    Args:
      attachment: An MJCF `RootElement`

    Returns:
      An `mjcf.Element` corresponding to the attachment frame. A joint can be
      added directly to this frame to give degrees of freedom to the attachment.

    Raises:
      ValueError: If `other` is not a valid attachment to this element.
    """
    if not isinstance(attachment, RootElement):
      raise ValueError('Expected a mjcf.RootElement: got {}'
                       .format(attachment))
    if attachment.namescope.parent is not None:
      raise ValueError('The model specified is already attached elsewhere')
    if attachment.namescope == self.namescope:
      raise ValueError('Cannot merge a model to itself')
    self.root._attach(attachment, exclude_worldbody=True, dry_run=True)  # pylint: disable=protected-access

    if self.namescope.has_identifier('namescope', attachment.model):
      id_number = 1
      while self.namescope.has_identifier(
          'namescope', '{}_{}'.format(attachment.model, id_number)):
        id_number += 1
      attachment.model = '{}_{}'.format(attachment.model, id_number)
    attachment.namescope.parent = self.namescope

    if self.tag == constants.WORLDBODY:
      frame_parent = self
      frame_siblings = self._children
      index = len(frame_siblings)
    else:
      frame_parent = self._parent
      frame_siblings = self._parent._children  # pylint: disable=protected-access
      index = frame_siblings.index(self) + 1
      while (index < len(frame_siblings)
             and isinstance(frame_siblings[index], _AttachmentFrame)):
        index += 1
    frame = _AttachmentFrame(frame_parent, self, attachment)
    frame_siblings.insert(index, frame)
    self.root._attach(attachment, exclude_worldbody=True)  # pylint: disable=protected-access
    return frame
def attach ( self , attachment ) : if not isinstance ( attachment , RootElement ) : raise ValueError ( 'Expected a mjcf.RootElement: got {}' . format ( attachment ) ) if attachment . namescope . parent is not None : raise ValueError ( 'The model specified is already attached elsewhere' ) if attachment . namescope == self . namescope : raise ValueError ( 'Cannot merge a model to itself' ) self . root . _attach ( attachment , exclude_worldbody = True , dry_run = True ) # pylint: disable=protected-access if self . namescope . has_identifier ( 'namescope' , attachment . model ) : id_number = 1 while self . namescope . has_identifier ( 'namescope' , '{}_{}' . format ( attachment . model , id_number ) ) : id_number += 1 attachment . model = '{}_{}' . format ( attachment . model , id_number ) attachment . namescope . parent = self . namescope if self . tag == constants . WORLDBODY : frame_parent = self frame_siblings = self . _children index = len ( frame_siblings ) else : frame_parent = self . _parent frame_siblings = self . _parent . _children # pylint: disable=protected-access index = frame_siblings . index ( self ) + 1 while ( index < len ( frame_siblings ) and isinstance ( frame_siblings [ index ] , _AttachmentFrame ) ) : index += 1 frame = _AttachmentFrame ( frame_parent , self , attachment ) frame_siblings . insert ( index , frame ) self . root . _attach ( attachment , exclude_worldbody = True ) # pylint: disable=protected-access return frame