📄 worldmodel.h
字号:
/*************************************************************************** * Copyright (C) 2005 by Rujia Liu * * rujialiu@hotmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/#ifndef WORLDMODEL_H#define WORLDMODEL_H#include <soccer/soccertypes.h>#include "physics.h"#include "logserver.h"class WMBuilder;class WorldModel{protected: // field parameters float mFieldLength; float mFieldWidth; float mFieldHeight; float mGoalWidth; float mGoalDepth; float mGoalHeight; float mBorderSize; // role information TTeamIndex mTeamIndex; unsigned int mTeamUnum; std::string mTeamName; std::string mOppTeamName; // game state. // mTime: time (in float) of the generation time of last vision (time[1]). // This is the same as the 'time' field in raw data float mTime; TPlayMode mPlayMode; // agent state float mBattery; float mTemperature; salt::Vector3f mMyDebugPos;public: WorldModel(); ~WorldModel(); // field parameter float GetFieldWidth() { return mFieldWidth; } float GetFieldLength() { return mFieldLength; } float GetFieldHeight() { return mFieldHeight; } float GetGoalWidth() { return mGoalWidth; } float GetGoalDepth() { return mGoalDepth; } float GetGoalHeight() { return mGoalHeight; } float GetBorderSize() { return mBorderSize; } // agent parameter float GetAgentMass() { return physics.mAgentMass; } float GetAgentRadius() { return physics.mAgentRadius; } float GetAgentMaxSpeed() { return physics.mAgentMaxSpeed; } float GetKickRange() { return physics.mKickRange; } // ball parameter float GetBallRadius() { return physics.mBallRadius; } float GetBallMass() { return physics.mBallMass; } // role information TTeamIndex GetTeamIndex() { return mTeamIndex; } int GetTeamNo() { return mTeamIndex == TI_LEFT ? 1 : 2;} // most likely used by trainer, since an integer must be provided int GetTeamUnum() { return mTeamUnum; } void SetTeamName(std::string name){ mTeamName = name; } void SetOppTeamName(std::string name){ mOppTeamName = name; } std::string GetTeamName(){ return mTeamName; } std::string GetOppTeamName(){ return mOppTeamName; } // game state int GetSimTime(int t = 0) { return physics.time[t]; } float GetTime(int t = 0) { return mTime + (physics.time[t] - physics.time[1]) / 100.0; } TPlayMode GetPlayMode(){ return mPlayMode; } // agent state float GetBattery() { return mBattery; } float GetTemperature() { return mTemperature; } public: // proxy routines salt::Vector3f GetMyDebugPosition() { return mMyDebugPos; } // our_team = 0, enemy_team = 1 // currently the estimation is not very accurate. salt::Vector3f GetPlayerPosition(int team, int unum, int t = 0) { return physics.GetPlayerPosition(team, unum, t); } salt::Vector3f GetMyPosition(int t = 0) { return physics.GetMyPosition(t); } salt::Vector3f GetBallPosition(int t = 0) { return physics.GetBallPosition(t); } salt::Vector3f GetPlayerSpeed(int team, int unum, int t = 0) { return physics.GetPlayerSpeed(team, unum, t); } salt::Vector3f GetBallSpeed(int t = 0) { return physics.GetBallSpeed(t); } salt::Vector3f GetMySpeed(int t = 0) { return physics.GetMySpeed(t); } salt::Vector3f GetBallStopPosition() { return physics.GetBallStopPosition(); }; salt::Vector3f GetStopDriveForce() { return physics.GetStopDriveForce(); }; int GetNearestPlayer(salt::Vector3f pos, int team); // returns estimated time, which should lie in [min, max]. // min and max are NOT considered initial speed, while `time' considers. int GetPlayerGotoTime(salt::Vector3f pos, int team, int unum, int &min_time, int& max_time); int GetMyGotoTime(salt::Vector3f pos, int& min_time, int& max_time); // obstacle avoiding salt::Vector3f TransformTarget(salt::Vector3f pos); Physics physics;public: // log system LogServer log; LogServer logvision; LogServer logcur; void LogWM(); friend class WMBuilder;};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -