(self, physics, random_state)
Sets initial tool center point pose via inverse kinematics.

    Args:
      physics: An `mjcf.Physics` instance.
      random_state: An `np.random.RandomState` instance.

    Raises:
      RuntimeError: If a collision-free pose could not be found within
        `max_ik_attempts`.
Sets initial tool center point pose via inverse kinematics.
Sets initial tool center point pose via inverse kinematics .
def __call__(self, physics, random_state):
    """Sets initial tool center point pose via inverse kinematics.

    Args:
      physics: An `mjcf.Physics` instance.
      random_state: An `np.random.RandomState` instance.

    Raises:
      RuntimeError: If a collision-free pose could not be found within
        `max_ik_attempts`.
    """
    if self._hand is not None:
      target_site = self._hand.tool_center_point
    else:
      target_site = self._arm.wrist_site

    initial_qpos = physics.bind(self._arm.joints).qpos.copy()

    for _ in range(self._max_rejection_samples):
      target_pos = variation.evaluate(self._position,
                                      random_state=random_state)
      target_quat = variation.evaluate(self._quaternion,
                                       random_state=random_state)
      success = self._arm.set_site_to_xpos(
          physics=physics, random_state=random_state, site=target_site,
          target_pos=target_pos, target_quat=target_quat,
          max_ik_attempts=self._max_ik_attempts)

      if success:
        physics.forward()  # Recalculate contacts.
        if (self._ignore_collisions
            or not self._has_relevant_collisions(physics)):
          return

      # If IK failed to find a solution for this target pose, or if the solution
      # resulted in contacts, then reset the arm joints to their original
      # positions and try again with a new target.
      physics.bind(self._arm.joints).qpos = initial_qpos

    raise RuntimeError(_REJECTION_SAMPLING_FAILED.format(
        max_rejection_samples=self._max_rejection_samples,
        max_ik_attempts=self._max_ik_attempts))
def __call__ ( self , physics , random_state ) : if self . _hand is not None : target_site = self . _hand . tool_center_point else : target_site = self . _arm . wrist_site initial_qpos = physics . bind ( self . _arm . joints ) . qpos . copy ( ) for _ in range ( self . _max_rejection_samples ) : target_pos = variation . evaluate ( self . _position , random_state = random_state ) target_quat = variation . evaluate ( self . _quaternion , random_state = random_state ) success = self . _arm . set_site_to_xpos ( physics = physics , random_state = random_state , site = target_site , target_pos = target_pos , target_quat = target_quat , max_ik_attempts = self . _max_ik_attempts ) if success : physics . forward ( ) # Recalculate contacts. if ( self . _ignore_collisions or not self . _has_relevant_collisions ( physics ) ) : return # If IK failed to find a solution for this target pose, or if the solution # resulted in contacts, then reset the arm joints to their original # positions and try again with a new target. physics . bind ( self . _arm . joints ) . qpos = initial_qpos raise RuntimeError ( _REJECTION_SAMPLING_FAILED . format ( max_rejection_samples = self . _max_rejection_samples , max_ik_attempts = self . _max_ik_attempts ) )