⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 worldmodel.cpp

📁 自己写的robocup-2d程序
💻 CPP
📖 第 1 页 / 共 5 页
字号:
{
  return agentObject.getGlobalBodyAngle(  );
}

/*! This method returns the stamina information of the agent
    \return Stamina stamina of the agent */
Stamina WorldModel::getAgentStamina( ) const
{
  return agentObject.getStamina();
}

/*! This method returns a TiredNessT value that indicates how tired the agent
   is.
	 \return TiredNessT value that indicates how tired the agent is. */
TiredNessT WorldModel::getAgentTiredNess( ) const
{
  return getAgentStamina().getTiredNess(
	                  SS->getRecoverDecThr(), SS->getStaminaMax() );
}

/*! This method returns the effort information of the agent
    \return double effort of the agent */
double WorldModel::getAgentEffort( ) const
{
  return agentObject.getStamina().getEffort();
}

/*! This method returns the global velocity information of the agent
    \return global velocity of the agent */
VecPosition WorldModel::getAgentGlobalVelocity( ) const
{
  return agentObject.getGlobalVelocity();
}

/*! This method returns the speed of the agent
    \return speed of the agent */
double WorldModel::getAgentSpeed( ) const
{
  return agentObject.getSpeed();
}

/*! This method returns the global position of the agent
    \return global position of the agent */
VecPosition WorldModel::getAgentGlobalPosition( ) const
{
  return agentObject.getGlobalPosition();
}

/*! This method sets the view angle of the agent.
    \return bool indicating whether update was successful.  */
bool WorldModel::setAgentViewAngle( ViewAngleT va ) 
{
  agentObject.setViewAngle( va );
  return true;
}


/*! This method returns the view angle of the agent.  

    \return ViewAngleT view angle of the agent (VA_NARROW, VA_NORMAL,
    VA_WIDE)*/
ViewAngleT WorldModel::getAgentViewAngle( ) const
{
  return agentObject.getViewAngle();
}

/*! This method sets the view quality of the agent.
    \return bool indicating whether update was successful.  */
bool WorldModel::setAgentViewQuality( ViewQualityT vq ) 
{
  agentObject.setViewQuality( vq );
  return true;
}
/*! This method returns the view quality of the agent
    \return ViewQualityT of the agent (VA_LOW, VA_HIGH). */
ViewQualityT WorldModel::getAgentViewQuality( ) const
{
  return agentObject.getViewQuality();
}

/*! This method returns the view frequency of see messages for the agent
    relative to the time of the sense_body interval. So 0.5 means a see
    message arrives twice in every simulation cycle.
    \return double representing the view frequency */
double WorldModel::getAgentViewFrequency( ViewAngleT va, ViewQualityT vq )
{
  double dViewQualityFactor ;
  double dViewWidthFactor   ;

  if( va == VA_ILLEGAL )
    va = getAgentViewAngle();
  if( vq == VQ_ILLEGAL )
    vq = getAgentViewQuality();

  switch( va )
  {
    case VA_NARROW:  dViewWidthFactor   = 0.5; break;
    case VA_NORMAL:  dViewWidthFactor   = 1.0; break;
    case VA_WIDE:    dViewWidthFactor   = 2.0; break;
    case VA_ILLEGAL:
    default:         dViewWidthFactor   = 0.0; break;
  }

  switch( vq )
  {
    case VQ_LOW:     dViewQualityFactor = 0.5; break;
    case VQ_HIGH:    dViewQualityFactor = 1.0; break;
    case VQ_ILLEGAL:
    default:         dViewQualityFactor = 0.0; break;
  }

  return dViewQualityFactor*dViewWidthFactor;
}

/*! This method returns whether the arm of the agent can be moved. */
bool WorldModel::getAgentArmMovable( )
{
  return agentObject.getArmMovable();
}

/*! This method returns the current position the arm of the agent is 
    pointing towards. */
VecPosition WorldModel::getAgentArmPosition( )
{
  return agentObject.getGlobalArmPosition();
}

/*! This method returns how many cycles it will last before the arm
    of the agent stops pointing. */
int WorldModel::getAgentArmExpires( )
{
  return agentObject.getArmExpires();
}

/*! This method returns the global position of the ball. The method
    getConfidence with as argument OBJECT_BALL should be called to check the
    confidence of this global position.
    \return global position bal. */
VecPosition  WorldModel::getBallPos()
{
  return getGlobalPosition( OBJECT_BALL );
}

/*! This method returns the current estimate of the speed of the ball.
    \return speed of the ball (magnitude of the global velocity vector). */
double WorldModel::getBallSpeed()
{
  return Ball.getGlobalVelocity().getMagnitude();
}

/*! This method returns the global direction of the ball velocity.
    \return global direction of the ball velocity */
AngDeg WorldModel::getBallDirection()
{
  return Ball.getGlobalVelocity().getDirection();
}

/*! This method returns the time of the global position
    of the specified object.
    \param ObjectT that represent the type of the object to check
    \return time corresponding to the global position of 'o' */
Time WorldModel::getTimeGlobalPosition( ObjectT o )
{
  PlayerObject *object = (PlayerObject*) getObjectPtrFromType( o );
  if( object != NULL )
    return object->getTimeGlobalPosition();
  return UnknownTime;
}


/*! This method returns the global position of an objectType. This
    method is normally used for the objects on the field (player,
    opponents and the ball).  When the global position cannot be
    determined, a VecPosition with both the x and y coordinate are set
    to 'UnknownDoubleValue'.

    \param ObjectT that represent the type of the object to check
    \return VecPosition containing the global position. */
VecPosition WorldModel::getGlobalPosition( ObjectT o )
{
  Object *object = getObjectPtrFromType( o );
  if( object != NULL )
  {
    if( SoccerTypes::isFlag( o ) || SoccerTypes::isGoal( o ) )
      return SoccerTypes::getGlobalPositionFlag( o, getSide(),
                                                 SS->getGoalWidth() );
    else
      return object->getGlobalPosition();
  }
  return VecPosition( UnknownDoubleValue, UnknownDoubleValue);
}

/*! This method returns the time of the global velocity
    of the specified object.
    \param ObjectT that represent the type of the object to check
    \return time corresponding to the global velocity of 'o' */
Time WorldModel::getTimeGlobalVelocity( ObjectT o )
{
  PlayerObject *object = (PlayerObject*) getObjectPtrFromType( o );
  if( object != NULL )
    return object->getTimeGlobalVelocity();
    Time time(-20,0);
    return time;
//  return UnknownTime;
}


/*! This method returns the global velocity of an objectType. When the
    global position cannot be determined, a VecPosition is returned with
    both the x and y coordinate set to 'UnknownDoubleValue'.
    \param ObjectT that represent the type of the object to check
    \return VecPosition containing the global position. */
VecPosition WorldModel::getGlobalVelocity( ObjectT o )
{
  DynamicObject *object = (DynamicObject*)getObjectPtrFromType( o );
  if( object != NULL )
    return object->getGlobalVelocity(  );
  return VecPosition( UnknownDoubleValue, UnknownDoubleValue );

}

/*! This method returns the relative distance between the agent and the object
    supplied as the first argument. No check is made whether this information
    is up to date (use isVisible or getConfidence for that).
    \param ObjectT that represent the type of the object to check
    \return relative distance to this object */
double WorldModel::getRelativeDistance( ObjectT o )
{
  Object *object = getObjectPtrFromType( o );
  if( object != NULL )
    return object->getRelativeDistance();
  return UnknownDoubleValue;
}

/*! This method returns the relative position of the object to the agent.
    No check is made whether this information is up to date (use isVisible or
    getConfidence for that).
    \param ObjectT that represent the type of the object to check
    \return relative position to this object */
VecPosition  WorldModel::getRelativePosition( ObjectT o )
{
  Object *object = getObjectPtrFromType( o );
  if( object != NULL )
    return object->getRelativePosition();
  return VecPosition(UnknownDoubleValue, UnknownDoubleValue);
}

/*! This method returns the relative angle between the agent and the object
    supplied as the first argument. No check is made whether this information
    is up to date (use isVisible or getConfidence for that).
    By default the returned angle is relative to the neck
    of the agent. When the second argument 'bWithBody' is set to true, the
    returned angle is relative to the body of the agent.
    \param ObjectT that represent the type of the object to check
    \param bWithBody when true angle is relative to body, otherwise to neck
           (default false)
    \return relative angle to this object */
AngDeg WorldModel::getRelativeAngle( ObjectT o, bool bWithBody )
{
  Object *object = getObjectPtrFromType( o );
  double dBody   = 0.0;

  if( object != NULL )
  {
    if( bWithBody == true )
      dBody = getAgentBodyAngleRelToNeck();
    return VecPosition::normalizeAngle( object->getRelativeAngle() - dBody );
  }
  return UnknownDoubleValue;
}

/*! This method returns the time of the global angles (both body and
    neck angle) of the specified object.

    \param ObjectT that represent the type of the object to check
    \return time corresponding to both the stored body and neck angle */
Time WorldModel::getTimeGlobalAngles( ObjectT o )
{
  PlayerObject *object = (PlayerObject*) getObjectPtrFromType( o );
  if( object != NULL )
    return object->getTimeGlobalAngles();
    Time time(-1,0);
    return time;
//  return Time( -1, 0);
}

/*! This method returns the global body angle of the specified object.
    No check is made whether this information is up to date (use
    getTimeGlobalAngles).
    \param ObjectT that represent the type of the object to check
    \return last known global body angle of this object */
AngDeg WorldModel::getGlobalBodyAngle( ObjectT o )
{
  PlayerObject *object = (PlayerObject*) getObjectPtrFromType( o );
  if( object != NULL )
    return object->getGlobalBodyAngle();
  return UnknownAngleValue;
}

/*! This method returns the global neck angle of the specified object.
    No check is made whether this information is up to date (use
    getTimeGlobalAngles).
    \param ObjectT that represent the type of the object to check
    \return last known global neck angle of this object */
AngDeg WorldModel::getGlobalNeckAngle( ObjectT o )
{
  PlayerObject *object = (PlayerObject*) getObjectPtrFromType( o );
  if( object != NULL )
    return object->getGlobalNeckAngle();
  return UnknownAngleValue;
}

/*! This method returns the global angle of the specified object (this object
    is normally a line).
    \param ObjectT that represent the type of the object to check
    \return global angle of this object in the field */
AngDeg WorldModel::getGlobalAngle( ObjectT o )
{
  if( SoccerTypes::isLine( o ) )
    return SoccerTypes::getGlobalAngleLine( o, getSide() );
  return UnknownAngleValue;
}


/*! This method returns the confidence value of the object
    supplied as the first argument. The confidence is calculated using the
    current server cycle and the time the object was last seen.
    \param ObjectT that represent the type of the object to check
    \return confidence value [0.0, 1.0] that indicates the confidence value */
double WorldModel::getConfidence( ObjectT o)
{
  Object *object = getObjectPtrFromType( o );
  if( object != NULL )
    return object->getConfidence( getCurrentTime() );

  return 0.0;
}

/*! This method returns wheter the specified object type is a known player.
    A known player is a player of which we know for certain that the player
    number is correct. If a player is seen without a number and it cannot be
    mapped to a player, it is put on the first empty position in the
    player list and the status of known player is set to false.
    \param o object type of player that should be checked
    \return bool indicating whether we are certain of number of player 'o'. */
bool WorldModel::isKnownPlayer( ObjectT o )
{
  PlayerObject *object = (PlayerObject *)getObjectPtrFromType( o );
  if( object != NULL  )
    return object->getIsKnownPlayer();
  return false;

}

/*! This method returns the object type of the opponent
    goalkeeper. Which object type is the actual goalkeeper is checked
    in different ways. First of all this information is can be
    available in a see message.  When no player is stored in the world
    model of which this is is perceived, the opponent goalkeeper is
    assumed the player with the highest x coordinate, but only if this

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -