(robot_class, leg_poses)
return motor_angles
Convert swing-extend coordinate space to motor angles for a robot type.

  Args:
    robot_class: This returns the class (not the instance) for the robot.
      Currently it supports minitaur, laikago and mini-cheetah.
    leg_poses: A list of leg poses in [swing,extend] or [abduction, swing,
      extend] space for all 4 legs. The order is [abd_0, swing_0, extend_0,
      abd_1, swing_1, extend_1, ...] or [swing_0, extend_0, swing_1, extend_1,
      ...]. Zero swing and zero extend gives a neutral standing pose for all the
      robots. For minitaur, the conversion is fully accurate, for laikago and
      mini-cheetah the conversion is approximate where swing is reflected to hip
      and extend is reflected to both knee and the hip.

  Returns:
    List of motor positions for the selected robot. The list include 8 or 12
    motor angles depending on the given robot type as an argument. Currently
    laikago and mini-cheetah has motors for abduction which does not exist for
    minitaur robot.

  Raises:
    ValueError: Conversion fails due to wrong inputs.
Convert swing-extend coordinate space to motor angles for a robot type.
Convert swing - extend coordinate space to motor angles for a robot type .
def convert_leg_pose_to_motor_angles(robot_class, leg_poses):
  """Convert swing-extend coordinate space to motor angles for a robot type.

  Args:
    robot_class: This returns the class (not the instance) for the robot.
      Currently it supports minitaur, laikago and mini-cheetah.
    leg_poses: A list of leg poses in [swing,extend] or [abduction, swing,
      extend] space for all 4 legs. The order is [abd_0, swing_0, extend_0,
      abd_1, swing_1, extend_1, ...] or [swing_0, extend_0, swing_1, extend_1,
      ...]. Zero swing and zero extend gives a neutral standing pose for all the
      robots. For minitaur, the conversion is fully accurate, for laikago and
      mini-cheetah the conversion is approximate where swing is reflected to hip
      and extend is reflected to both knee and the hip.

  Returns:
    List of motor positions for the selected robot. The list include 8 or 12
    motor angles depending on the given robot type as an argument. Currently
    laikago and mini-cheetah has motors for abduction which does not exist for
    minitaur robot.

  Raises:
    ValueError: Conversion fails due to wrong inputs.
  """
  if len(leg_poses) not in [8, 12]:
    raise ValueError("Dimension of the leg pose provided is not 8 or 12.")
  neutral_motor_angles = get_neutral_motor_angles(robot_class)
  motor_angles = leg_poses
  # If it is a robot with 12 motors but the provided leg pose does not contain
  # abduction, extend the pose to include abduction.
  if len(neutral_motor_angles) == 12 and len(leg_poses) == 8:
    for i in _ABDUCTION_ACTION_INDEXES:
      motor_angles.insert(i, 0)
  # If the robot does not have abduction (minitaur) but the input contains them,
  # ignore the abduction angles for the conversion.
  elif len(neutral_motor_angles) == 8 and len(leg_poses) == 12:
    del leg_poses[::3]

  # Minitaur specific conversion calculations using minitaur-specific safety
  # limits.
  if str(robot_class) == str(laikago.Laikago):
    swing_scale = 1.0
    extension_scale = 1.0
    # Laikago specific conversion multipliers.
    swing_scale = _LAIKAGO_SWING_CONVERSION_MULTIPLIER
    extension_scale = _LAIKAGO_EXTENSION_CONVERSION_MULTIPLIER
  else:
    motor_angles = robot_class.convert_leg_pose_to_motor_angles(leg_poses)

  return motor_angles
def convert_leg_pose_to_motor_angles ( robot_class , leg_poses ) : if len ( leg_poses ) not in [ 8 , 12 ] : raise ValueError ( "Dimension of the leg pose provided is not 8 or 12." ) neutral_motor_angles = get_neutral_motor_angles ( robot_class ) motor_angles = leg_poses # If it is a robot with 12 motors but the provided leg pose does not contain # abduction, extend the pose to include abduction. if len ( neutral_motor_angles ) == 12 and len ( leg_poses ) == 8 : for i in _ABDUCTION_ACTION_INDEXES : motor_angles . insert ( i , 0 ) # If the robot does not have abduction (minitaur) but the input contains them, # ignore the abduction angles for the conversion. elif len ( neutral_motor_angles ) == 8 and len ( leg_poses ) == 12 : del leg_poses [ : : 3 ] # Minitaur specific conversion calculations using minitaur-specific safety # limits. if str ( robot_class ) == str ( laikago . Laikago ) : swing_scale = 1.0 extension_scale = 1.0 # Laikago specific conversion multipliers. swing_scale = _LAIKAGO_SWING_CONVERSION_MULTIPLIER extension_scale = _LAIKAGO_EXTENSION_CONVERSION_MULTIPLIER else : motor_angles = robot_class . convert_leg_pose_to_motor_angles ( leg_poses ) return motor_angles