📄 worldmodel.cpp
字号:
{ 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' *///返回确切对象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. *///返回对象O的绝对位置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' *///返回估计出对象O的绝对速度时的时间Time WorldModel::getTimeGlobalVelocity( ObjectT o ){ PlayerObject *object = (PlayerObject*) getObjectPtrFromType( o ); if( object != NULL ) //对象存在,返回其时间 return object->getTimeGlobalVelocity(); 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. *///对象O的绝对速度(速度是用一个向量返回的)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 *///返回该队员到对象O的相对距离,该信息并不对信息的时效性做检查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 *///返回该队员到对象O的相对位置,该信息并不对信息的时效性做检查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 *///接收Agent相对于对象O的角度;//默认是相对于脖子的角度//当bWithBody为真的时候,是相对于身体的角度AngDeg WorldModel::getRelativeAngle( ObjectT o, bool bWithBody ){ Object *object = getObjectPtrFromType( o ); double dBody = 0.0; if( object != NULL ) { if( bWithBody == true ) //如果bWithBody为真,返回相对于身体的角度 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 \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(); 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 *///返回确切对象O的绝对角度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 *///返回确切对象O脖子的绝对角度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 *///返回对象O的绝对角度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 *///返回对象O的可信度的值,它是由服务器当前周期和上次看到O对象的时间作决定的double WorldModel::getConfidence( ObjectT o){ Object *object = getObjectPtrFromType( o ); if( object != NULL ) //如果对象存在,返回其可信度 return object->getConfidence( getCurrentTime() ); //否则 0.0 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'. *///判断对象O是否为可知队员,一个可知的球员是一个我们可以正确看清他们号码的球员。//如果没办法看清队员的号码时,它将被放入不可知队员列表然后可知性将被设定为falsebool 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 player stands very close in front of the goal \return ObjectT that represents the opponent goalkeeper, OBJECT_ILLEGAL if it cannot be determined which object type is the opponent goalkeeper. *///返回敌方守门员的对象类型。判定守门员的位置有多种方法,首先通过视觉信息尝试看到守门员,//如果没有人注意到守门员的位置,则判定X坐标最大且站在球门前附近的球员为对方守门员。ObjectT WorldModel::getOppGoalieType(){ //默认为非法对象 static ObjectT objGoalieType = OBJECT_ILLEGAL; //如果为非非法对象,且可信度好,并且是可见球员,返回守门员类型 if( objGoalieType != OBJECT_ILLEGAL && isConfidenceGood( objGoalieType ) && isKnownPlayer( objGoalieType ) ) return objGoalieType; //用于寻找X坐标最大的对方球员 ObjectT objOppMaxX = OBJECT_ILLEGAL; double x = -100.0; //枚举对方所有球员,寻找X坐标最大的。 //这个循环相当于一轮简单的选择排序。 for( int i = 0; i < MAX_OPPONENTS; i++ ) //i小于敌方队员数 { //如果可信度好 if( isConfidenceGood( Opponents[i].getType( ) ) ) { //如果可以确定对象是守门员 if( Opponents[i].getIsGoalie() == true ) { objGoalieType = Opponents[i].getType(); return Opponents[i].getType(); } //如果队员(i)的X坐标最大,且Y坐标在一定范围内(属于新增判定条件) if( Opponents[i].getGlobalPosition().getX() > x && fabs(Opponents[i].getGlobalPosition().getY())<(PENALTY_AREA_W_HALF)*0.6) { x = Opponents[i].getGlobalPosition().getX(); objOppMaxX = Opponents[i].getType(); } } } // if opponent with highest x is nr 1, assume it is goalkeeper when standing // in own penalty area, otherwise assume goalkeeper closest player to goal. // 如果X坐标最大的球员为一号,如果他在禁区内就假设是守门员,否则选择离球门最近的是守门员 if( (objOppMaxX == OBJECT_OPPONENT_1 && x > PENALTY_X + 5.0 ) || //站在禁区中 (objOppMaxX != OBJECT_ILLEGAL && x > PITCH_L_HALF - 5.0 ) ) //站在指定区域的球员 return objOppMaxX; return OBJECT_ILLEGAL;}/*! This method returns the object type of the own goalkeeper. Which object type is the actual goalkeeper is checked in different ways. First of all this information is available in the see, when (goalie) is behind the perceived object. When no player is stored in the world model of which this is perceived, the own goalkeeper is assumed the player with the lowest x coordinate, but only if this player stands close in front of the goal. \return ObjectT that represents the own goalkeeper, OBJECT_ILLEGAL if it cannot be determined which object type is the own goalkeeper. *///返回我方守门员的类型,基本判定方法同上ObjectT WorldModel::getOwnGoalieType(){ ObjectT objOwnMinX = OBJECT_ILLEGAL; double x = 100.0; for( int i = 0; i < MAX_TEAMMATES; i++ ) { if( isConfidenceGood( Teammates[i].getType( ) ) ) { if( Teammates[i].getIsGoalie() == true ) return Teammates[i].getType(); if( Teammates[i].getGlobalPosition().getX() < x && fabs(Teammates[i].getGlobalPosition().getY())<(PENALTY_AREA_W_HALF)*0.6) { x = Teammates[i].getGlobalPosition().getX(); objOwnMinX = Teammates[i].getType(); } } } if( ( objOwnMinX == OBJECT_TEAMMATE_1 && x < - ( PENALTY_X + 4.0 ) ) || (objOwnMinX != OBJECT_ILLEGAL && x < - PITCH_LENGTH/2.0 + 6.0 )) return objOwnMinX; return OBJECT_ILLEGAL;}/*! This method returns the last server cycle the specified object has been seen. \param object type of object that should be checked \return server time this object was last seen (in a see message). *///返回对象O上次被看见的时间Time WorldModel::getTimeLastSeen( ObjectT o ){ Object *object = getObjectPtrFromType( o ); if( object != NULL ) return object->getTimeLastSeen( ); return Time( -1, 0);}/*! This method returns the last server cycle the relative distance change of the specified object has been reported. \param object type of object that should be checked \return server time relative distance change of this object was last seen (in a see message). *///返回上次报告和指定物体相对距离改变时服务器的周期Time WorldModel::getTimeChangeInformation( ObjectT o ){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -