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

📄 worldmodel.h

📁 robocup3d源化码 Nexus3D.tar.gz
💻 H
字号:
/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-   this file is part of rcssserver3D   Fri May 9 2003   Copyright (C) 2002,2003 Koblenz University   Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group   $Id: worldmodel.h,v 1.7 2004/04/08 14:27:29 markelic Exp $   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; version 2 of the License.   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., 675 Mass Ave, Cambridge, MA 02139, USA.*/#ifndef WORLDMODEL_H#define WORLDMODEL_H#include <string>#include <map>#include <zeitgeist/leaf.h>#include <soccer/soccertypes.h>#include <oxygen/gamecontrolserver/predicate.h>#include <oxygen/gamecontrolserver/baseparser.h>#include "types.h"const int Max_InputMesg = 4000;	//maximum length of an input messageclass WorldModel : public zeitgeist::Leaf{public:    WorldModel();    virtual ~WorldModel();    /** parses a message received from the server */    void Parse(const std::string& message);    /** returns the polar coordinates of the requested object */    pol GetVisionSense(VisionObject obj);    /** returns the global cartesian coordinates of the sensed        object */    salt::Vector3f GetPosition(pol sense);    /** returns the coordinates of the requested object */    salt::Vector3f GetObjectPosition(VisionObject obj);    /** returns the current PlayMode */    TPlayMode GetPlayMode();    /** given an object position in polar coordinates and distance,        CalcDriveVec returns a cartesian normalized vector that can be        passed to the drive effector to reach this position.    */    salt::Vector3f GetDriveVec(const pol& vision);    /** returns the players calculated position */    salt::Vector3f GetMyPosition();    /** returns the players team index */    TTeamIndex GetMyTeam();    float GetFieldWidth() { return mFieldWidth; }    float GetFieldLength() { return mFieldLength; }    float GetAgentRadius() { return mAgentRadius; }    float GetBallRadius() { return mBallRadius; }    float GetMinimalKickDistance();    int GetTeamUnum();        void SetTeamName(std::string name);      std::string GetTeamName();                 std::string GetOppTeamName();protected:    virtual bool ConstructInternal();    void CalcPlayerPosition();    void ParseObjectVision(const oxygen::Predicate& predicate);    void ParseGameState(const oxygen::Predicate& predicate);    void ParseVision(const oxygen::Predicate& predicate);    void ParsePlayMode(const oxygen::Predicate& predicate);    void ParseTeamIndex(const oxygen::Predicate& predicate);    void SetupGameStateMap();    void SetupVisionObjectMap();protected:    // mapping from gamestate string to TPlayMode    typedef std::map<std::string, TPlayMode> TPlayModeMap;    TPlayModeMap mPlayModeMap;    // mapping from vision object to pol    typedef std::map<VisionObject, pol> TVisionMap;    TVisionMap mVisionMap;    // mapping from <ObjectName>+<ID> to VisionObject    typedef std::map<std::string, VisionObject> TVisionObjectMap;    TVisionObjectMap mVisionObjectMap;    // parser instance    boost::shared_ptr<oxygen::BaseParser> mParser;        void SetOppTeamName(std::string name);    // soccer variables    float mFieldLength;    float mFieldWidth;    float mFieldHeight;    float mGoalWidth;    float mGoalDepth;    float mGoalHeight;    float mBorderSize;    // agent parameter    float mAgentMass;    float mAgentRadius;    float mAgentMaxSpeed;    // ball parameter    float mBallRadius;    float mBallMass;    // team information    TTeamIndex mTeamIndex;    unsigned int mTeamUnum;    std::string mTeamName;    std::string mOppTeamName;    // game state information    float mTime;    TPlayMode mPlayMode;    // the players position    salt::Vector3f mMyPos;/******************* previous parser class *********************/	bool sw_their_team_name;	char input_string[Max_InputMesg];	int parse_counter;	pol static_objects_polar_relpos2me[9];//ball, flags and goal (VisionObject enumerator)	pol players_polar_relpos2me[2][12];//[0]:my players, [1]:their players	void parse_flags();	void parse_goals();	void parse_ball();	void parse_vision_object(int);	void parse_player();	void parse_player1();	float WorldModel:: conv_ch_do ();	float string2float();//input : input_string[parse_counter]	void ResetObjects();//set pol.is_new to false before the parse phase	void set_my_position();	void set_ball_position();	void set_players_position();	void parse_vision(const char *);};DECLARE_CLASS(WorldModel);#endif // WORLDMODEL_H

⌨️ 快捷键说明

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