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

📄 objects.cpp

📁 2003年RoboCup仿真组世界冠军源代码 足球机器人 仿真组 的源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
}/*! This method returns the relative angle change of this object.    This information belongs to the server time that is returned by    getTimeChangeInformation().    \return relative angle change of object in the last cycle */double DynamicObject::getRelativeAngleChange() const{  return dRelativeAngleChange;}/*! This method sets the time the change information was calculated.    \param time time information for change was calculated    \return bool indicating whether the values was set */bool DynamicObject::setTimeChangeInformation( Time time ){  timeChangeInformation = time ;  return true;}/*! This method returns the server time that belongs to the relative distance    and relative angle change of this object.    \return time of the change information of this DynamicObject */Time DynamicObject::getTimeChangeInformation()  const{  return timeChangeInformation;}/*! This method sets the global velocity of the object calculated after the last    see message. The time of this information corresponds to    'getTimeChangeInformation'.     \return global body velocity derived from the last see message */bool DynamicObject::setGlobalVelocityLastSee ( VecPosition vec ){  vecGlobalVelocityLastSee = vec;  return true;}/*! This method returns the global velocity of the object calculated after the     last see message. The time of this information corresponds to    'getTimeChangeInformation'.     \return global body velocity derived from the last see message */VecPosition DynamicObject::getGlobalVelocityLastSee ( )   const{  return vecGlobalVelocityLastSee;}/*****************************************************************************//********************* CLASS PLAYEROBJECT ************************************//*****************************************************************************//*! This is the constructor for PlayerObject. A PlayerObject is created with    all variables initialized to (illegal) default values */PlayerObject::PlayerObject( ):DynamicObject( ){  angGlobalBodyAngle   = UnknownAngleValue;  angGlobalNeckAngle   = UnknownAngleValue;  isKnownPlayer        = false;  isGoalie             = false;  angRelativeBodyAngle = UnknownAngleValue;  angRelativeNeckAngle = UnknownAngleValue;    iHeteroPlayerType    = 0;}/*! This method sets the facing direction of the body and the time of this    information (all relative to the agent).    \param ang new relative facing direction of body    \param time time corresponding to the facing direction    \return bool indicating whether the values were set */bool PlayerObject::setRelativeBodyAngle( AngDeg ang, Time time ){  angRelativeBodyAngle = ang;  setTimeRelativeAngles( time );  return true;}/*! This method returns the relative body angle of this object. This    information is from the server time that is returned by    getTimeRelativeAngles().    \return relative body angle of this object */AngDeg PlayerObject::getRelativeBodyAngle( )  const{  return angRelativeBodyAngle;}/*! This method sets the facing direction of the body and the time of this    information (all global).    \param ang new global facing direction of body    \param time time corresponding to the facing direction    \return bool indicating whether the values were set */bool PlayerObject::setGlobalBodyAngle( AngDeg ang, Time time){  angGlobalBodyAngle = ang;  setTimeGlobalAngles( time );  return true;}/*! This method returns the global body angle of this object. This information    is from the server time that is returned by getTimeGlobalAngles().    \return global body angle of this object */AngDeg PlayerObject::getGlobalBodyAngle( )  const{  return angGlobalBodyAngle;}/*! This method returns the facing direction of the neck and the time of    this information (all relative to the agent).    \param ang new relative facing direction of neck    \param time time facing direction was received    \return bool indicating whether the values were set */bool PlayerObject::setRelativeNeckAngle( AngDeg ang, Time time ){  angRelativeNeckAngle = ang;  setTimeRelativeAngles( time );  return true;}/*! This method returns the relative neck angle of this object. This    information is from  the time  that is returned by getTimeRelativeAngles().    \return relative neck angle of this object */AngDeg PlayerObject::getRelativeNeckAngle( )  const{  return angRelativeNeckAngle;}/*! This method returns the facing direction of the neck and the time of    this information (all global).    \param ang new global facing direction of neck    \param iTime time facing direction was received    \return bool indicating whether the values were set */bool PlayerObject::setGlobalNeckAngle( AngDeg ang, Time time ){  angGlobalNeckAngle = ang;  setTimeGlobalAngles( time );  return true;}/*! This method returns the global neck angle of this object. This    information is from  the time that is returned by getTimeGlobalAngles().    \return global neck angle of this object */AngDeg PlayerObject::getGlobalNeckAngle( )  const{  return angGlobalNeckAngle;}/*! This method sets the time the facing direction was calculated.    \param time time the facing direction was received    \return bool indicating whether the values were set */bool PlayerObject::setTimeRelativeAngles( Time time ){  timeRelativeAngles = time;  return true;}/*! This method returns the server time in which the relative body and neck    angle of this object were calculated.    \return time of the relative neck and body information */Time PlayerObject::getTimeRelativeAngles( ) const{  return timeRelativeAngles ;}/*! This method sets the time the facing direction was calculated.    \param time time the facing direction was received    \return bool indicating whether the values were set */bool PlayerObject::setTimeGlobalAngles( Time time ){  timeGlobalAngles = time;  return true;}/*! This method sets the global angle of the agent calculated after the last     see message. The time of this information corresponds to    'getTimeChangeInformation', since the change information arrives always    together with the body and neck information.     \return global body angle derived from the last see message */bool PlayerObject::setGlobalBodyAngleLastSee( AngDeg ang ){  angGlobalBodyAngleLastSee = ang;  return true;}/*! This method returns the global angle of the agent calculated after    the last see message. The time of this information corresponds to    'getTimeChangeInformation', since the change information arrives    always together with the body and neck information.    \return global body angle derived from the last see message */AngDeg PlayerObject::getGlobalBodyAngleLastSee( )  const{  return angGlobalBodyAngleLastSee;}  /*! This method returns the server time in which the global body and neck    angle of this object were calculated.    \return time of the global neck and body information */Time PlayerObject::getTimeGlobalAngles( ) const{  return timeGlobalAngles ;}/*! This method sets the possible range from which this object must originate    from. Since the ordening of objects in a 'see' message is always the same    (first teammates then opponents and always sorted by player number), it    is possible to derive the range of objects from which the supplied    information must originate.    \param objMin minimum object type    \param objMax maximum object type    \return bool indicating whether update was successful. */bool PlayerObject::setPossibleRange( ObjectT objMin, ObjectT objMax ){  objRangeMin = objMin;  objRangeMax = objMax;  return true;}/*! This method returns a boolean indicating whether the supplied object type,    is in the range of possible object types set by 'setPossibleRange'.    \param obj Object type that should be checked    \return boolean indicating whether 'obj' is located in the range. */bool PlayerObject::isInRange( ObjectT obj, bool bTeammatesFirst ){  int  iIndObj = SoccerTypes::getIndex( obj );  int  iIndMin = SoccerTypes::getIndex( objRangeMin );  int  iIndMax = SoccerTypes::getIndex( objRangeMax );  // teammates 0 to 10, opponents 11 to 21 or -10..1 I guess  if( SoccerTypes::isOpponent( obj ) )    iIndObj += ( bTeammatesFirst ) ? 11 : -11 ;  if( SoccerTypes::isOpponent( objRangeMin ) )    iIndMin += ( bTeammatesFirst ) ? 11 : -11 ;  if( SoccerTypes::isOpponent( objRangeMax ) )    iIndMax += ( bTeammatesFirst ) ? 11 : -11 ;    return iIndMin <= iIndObj && iIndObj <= iIndMax ;}/*! This method returns the minimal possible object type as set by   'setPossibleRange'.     \return minimal possible object type */ObjectT PlayerObject::getMinRange( ){  return objRangeMin;}/*! This method returns the maximal possible object type as set by   'setPossibleRange'.     \return maximal possible object type */ObjectT PlayerObject::getMaxRange( ){  return objRangeMax;}/*! This method sets whether this dynamic object is a known player or not.    A known player is a player of which we know the number. If we don't know    the player number of a player, the player is put at the index of a player    that isn't seen in a while and the isKnownPlayer attribute is set to false.    \param b bool indicating whether player number is known    \return bool indicating whether value was set. */bool PlayerObject::setIsKnownPlayer( bool b ){  isKnownPlayer = b;  return true;}/*! This method returns whether the current object is a known player or not.    A known player is a player of which we know the number. If we don't know    the player number of a player, the player is put at the index of a player    that isn't seen in a while and the isKnownPlayer attribute is set to false.    \return bool indicating whether player number is known */bool PlayerObject::getIsKnownPlayer() const{  return isKnownPlayer;}/*! This method sets whether this dynamic object is a goalie or not.    \param b bool indicating whether this dynamic object is a goalie    \return bool indicating whether value was set. */bool PlayerObject::setIsGoalie( bool b ){  isGoalie = b;  return true;}/*! This method returns whether the current object is a goalie or not.    \return bool indicating whether this dynamic object is a goalie or not */bool PlayerObject::getIsGoalie() const{  return isGoalie;}/*! This method prints the information about this PlayerObject to the specified    output stream. The variables are printed with the default team name.    \param os output stream to which output is written */void PlayerObject::show( ostream & os ){  show( DEFAULT_TEAM_NAME, os );}/*! This method prints the information about this PlayerObject to the specified    output stream. The variables are printed with the specified team name.    \param strTeamName team name of this player object    \param os output stream to which output is written */void PlayerObject::show( const char* strTeamName , ostream & os ){  char buf[MAX_TEAM_NAME_LENGTH];  SoccerTypes::getObjectStr( buf, objectType, strTeamName );  os << buf             << " conf: "              << getConfidence( timeGlobalPosition )            << " pos: "               << posGlobal            << ","                    << timeGlobalPosition            << " vel: "               << vecGlobalVelocity            << ","                    << timeGlobalVelocity            << " ang (b:"             << getGlobalBodyAngle()            << ",n:"                  << angGlobalNeckAngle            << "),"                   << timeGlobalAngles            << "known: "              << isKnownPlayer            << " lastseen:"            << timeLastSeen << "\n";}/*! This method sets the heterogeneous index number of this player object.    \param hetereogeneous index number     \return bool indicating whether update was successful. */bool PlayerObject::setHeteroPlayerType( int index ){  iHeteroPlayerType = index;  return true;}  /*! This method returns the heterogeneous index number of this player object.    \return hetereogeneous index number */int  PlayerObject::getHeteroPlayerType( ) const{  return iHeteroPlayerType;}/*! This method sets the time  related to the last tackle of this object. */bool PlayerObject::setTimeTackle( Time time ){  m_timeTackle = time;  return true;}/*! This method returns the time that is related to the last tackle    of this object.  */Time PlayerObject::getTimeTackle( ) const{  return m_timeTackle;}/*! This method sets the global direction in which the arm of this object    has last been observed to point. The time related to this update is     represented by time.  */bool PlayerObject::setGlobalArm( AngDeg ang, Time time ){  m_angGlobalArm = ang;  return setTimeGlobalArm( time );}/*! This method returns the global direction in which the arm of this object    has last been observed to point.  */AngDeg PlayerObject::getGlobalArm( ) const{  return m_angGlobalArm;}/*! This method sets the time that is related to the last time the arm     of this object has been observed to point in the global direction returned    by 'getGlobalArm'. */bool PlayerObject::setTimeGlobalArm( Time time ){  m_timeGlobalArm = time;  return true;}/*! This method returns the time that is related to the last time the arm of    this object has been observed to point in the global direction returned    by 'getGlobalArm'. */Time PlayerObject::getTimeGlobalArm( ) const{  return m_timeGlobalArm;}/*****************************************************************************//********************* CLASS BALLOBJECT **************************************//*****************************************************************************//*! This is the constructor for a BallObject. It does nothing except    initializing the class. */BallObject::BallObject():DynamicObject(){}/*! This method prints information about the ball to the specified    output stream

⌨️ 快捷键说明

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