(self)
Builds action space based on motor control mode.
Builds action space based on motor control mode.
Builds action space based on motor control mode .
def _build_action_space(self):
    """Builds action space based on motor control mode."""
    motor_mode = self._gym_config.simulation_parameters.motor_control_mode
    if motor_mode == robot_config.MotorControlMode.HYBRID:
      action_upper_bound = []
      action_lower_bound = []
      action_config = self._robot_class.ACTION_CONFIG
      for action in action_config:
        action_upper_bound.extend([6.28] * 5)
        action_lower_bound.extend([-6.28] * 5)
      self.action_space = spaces.Box(np.array(action_lower_bound),
                                     np.array(action_upper_bound),
                                     dtype=np.float32)
    elif motor_mode == robot_config.MotorControlMode.TORQUE:
      # TODO (yuxiangy): figure out the torque limits of robots.
      torque_limits = np.array([100] * len(self._robot_class.ACTION_CONFIG))
      self.action_space = spaces.Box(-torque_limits,
                                     torque_limits,
                                     dtype=np.float32)
    else:
      # Position mode
      action_upper_bound = []
      action_lower_bound = []
      action_config = self._robot_class.ACTION_CONFIG
      for action in action_config:
        action_upper_bound.append(action.upper_bound)
        action_lower_bound.append(action.lower_bound)

      self.action_space = spaces.Box(np.array(action_lower_bound),
                                     np.array(action_upper_bound),
                                     dtype=np.float32)
def _build_action_space ( self ) : motor_mode = self . _gym_config . simulation_parameters . motor_control_mode if motor_mode == robot_config . MotorControlMode . HYBRID : action_upper_bound = [ ] action_lower_bound = [ ] action_config = self . _robot_class . ACTION_CONFIG for action in action_config : action_upper_bound . extend ( [ 6.28 ] * 5 ) action_lower_bound . extend ( [ - 6.28 ] * 5 ) self . action_space = spaces . Box ( np . array ( action_lower_bound ) , np . array ( action_upper_bound ) , dtype = np . float32 ) elif motor_mode == robot_config . MotorControlMode . TORQUE : # TODO (yuxiangy): figure out the torque limits of robots. torque_limits = np . array ( [ 100 ] * len ( self . _robot_class . ACTION_CONFIG ) ) self . action_space = spaces . Box ( - torque_limits , torque_limits , dtype = np . float32 ) else : # Position mode action_upper_bound = [ ] action_lower_bound = [ ] action_config = self . _robot_class . ACTION_CONFIG for action in action_config : action_upper_bound . append ( action . upper_bound ) action_lower_bound . append ( action . lower_bound ) self . action_space = spaces . Box ( np . array ( action_lower_bound ) , np . array ( action_upper_bound ) , dtype = np . float32 )