def get_neutral_motor_angles(robot_class):
    """Return a neutral (standing) pose for a given robot type.

  Args:
    robot_class: This returns the class (not the instance) for the robot.
      Currently it supports minitaur, laikago and mini-cheetah.

  Returns:
    Pose object for the given robot. It's either MinitaurPose, LaikagoPose or
    MiniCheetahPose.

  Raises:
    ValueError: If the given robot_class is different than the supported robots.
  """
    if str(robot_class) == str(laikago.Laikago):
        init_pose = np.array(
            attr.astuple(
                laikago_pose_utils.LaikagoPose(
                    abduction_angle_0=0,
                    hip_angle_0=_LAIKAGO_NEUTRAL_POSE_HIP_ANGLE,
                    knee_angle_0=_LAIKAGO_NEUTRAL_POSE_KNEE_ANGLE,
                    abduction_angle_1=0,
                    hip_angle_1=_LAIKAGO_NEUTRAL_POSE_HIP_ANGLE,
                    knee_angle_1=_LAIKAGO_NEUTRAL_POSE_KNEE_ANGLE,
                    abduction_angle_2=0,
                    hip_angle_2=_LAIKAGO_NEUTRAL_POSE_HIP_ANGLE,
                    knee_angle_2=_LAIKAGO_NEUTRAL_POSE_KNEE_ANGLE,
                    abduction_angle_3=0,
                    hip_angle_3=_LAIKAGO_NEUTRAL_POSE_HIP_ANGLE,
                    knee_angle_3=_LAIKAGO_NEUTRAL_POSE_KNEE_ANGLE)))
    else:
        init_pose = robot_class.get_neutral_motor_angles()
    return init_pose
 def __init__(
     self,
     init_abduction=laikago_pose_utils.LAIKAGO_DEFAULT_ABDUCTION_ANGLE,
     init_hip=laikago_pose_utils.LAIKAGO_DEFAULT_HIP_ANGLE,
     init_knee=laikago_pose_utils.LAIKAGO_DEFAULT_KNEE_ANGLE,
     action_limit=0.5,
 ):
   """Initializes the controller.
   Args:
     action_limit: a tuple of [limit_abduction, limit_hip, limit_knee]
   """
   self._pose = np.array(
       attr.astuple(
           laikago_pose_utils.LaikagoPose(abduction_angle_0=init_abduction,
                                          hip_angle_0=init_hip,
                                          knee_angle_0=init_knee,
                                          abduction_angle_1=init_abduction,
                                          hip_angle_1=init_hip,
                                          knee_angle_1=init_knee,
                                          abduction_angle_2=init_abduction,
                                          hip_angle_2=init_hip,
                                          knee_angle_2=init_knee,
                                          abduction_angle_3=init_abduction,
                                          hip_angle_3=init_hip,
                                          knee_angle_3=init_knee)))
   action_high = np.array([action_limit] * 12)
   self.action_space = spaces.Box(-action_high, action_high, dtype=np.float32)
Exemple #3
0
 def __init__(
     self,
     pose,
     action_limit=0.5,
 ):
     """Initializes the controller.
   Args:
     action_limit: a tuple of [limit_abduction, limit_hip, limit_knee]
   """
     self._pose = np.array(
         attr.astuple(
             laikago_pose_utils.LaikagoPose(abduction_angle_0=pose[0],
                                            hip_angle_0=pose[1],
                                            knee_angle_0=pose[2],
                                            abduction_angle_1=pose[3],
                                            hip_angle_1=pose[4],
                                            knee_angle_1=pose[5],
                                            abduction_angle_2=pose[6],
                                            hip_angle_2=pose[7],
                                            knee_angle_2=pose[8],
                                            abduction_angle_3=pose[9],
                                            hip_angle_3=pose[10],
                                            knee_angle_3=pose[11])))
     action_high = np.array([action_limit] * 12)
     self.action_space = spaces.Box(-action_high,
                                    action_high,
                                    dtype=np.float32)