📄 objects.c
字号:
/*! This method returns the speed of this object. The speed is the magnitude of the global velocity of the object \return speed of this object (zero for non-moving objects) */double DynamicObject::getSpeed( ) const{ return vecGlobalVelocity.getMagnitude();}/*! This method sets the time that corresponds to the last update of the global velocity of this object. \param time time corresponding to current value of global velocity \return bool indicating whether the value was set */bool DynamicObject::setTimeGlobalVelocity( Time time ){ timeGlobalVelocity = time; return true;}/*! This method returns the time that belongs to the global velocity of this object. \return time of the global velocity of this object */Time DynamicObject::getTimeGlobalVelocity() const{ return timeGlobalVelocity;}/*! This method sets the relative distance change and the time this information was calculated. \param d new relative distance change \param time time relative distance change was calculated \return bool indicating whether the values were set */bool DynamicObject::setRelativeDistanceChange( double d, Time time ){ dRelativeDistanceChange = d; setTimeChangeInformation( time ); return true;}/*! This method returns the relative distance change of this object. Note that this value is zero when object is at the same distance, but at a complete different angle. This occurs when an object has moved a lot in one cycle. This information belongs to the server time that is returned by getTimeChangeInformation(). \return relative distance change of object in the last cycle */double DynamicObject::getRelativeDistanceChange() const{ return dRelativeDistanceChange;}/*! This method sets the relative angle change and the server time this information belongs to. \param d new relative angle change \param time time relative angle change was received \return bool indicating whether the values were set */bool DynamicObject::setRelativeAngleChange( double d, Time time ){ dRelativeAngleChange = d; setTimeChangeInformation( time ); return true;}/*! 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;}/******************************************************************************//********************** 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;}/*! 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 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 ){ int iIndObj = SoccerTypes::getIndex( obj ); int iIndMin = SoccerTypes::getIndex( objRangeMin ); int iIndMax = SoccerTypes::getIndex( objRangeMax ); if( SoccerTypes::isOpponent( obj ) ) iIndObj += 11; if( SoccerTypes::isOpponent( objRangeMin ) ) iIndMin += 11; if( SoccerTypes::isOpponent( objRangeMax ) ) iIndMax += 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 << endl;}/******************************************************************************//********************** CLASS BALLOBJECT **************************************//******************************************************************************//*! This is the constructor for a BallObject. It does nothing except initializing the class. */BallObject::BallObject():DynamicObject()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -