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

📄 main.cpp

📁 robocup3d源化码 Nexus3D.tar.gz
💻 CPP
字号:
/* -*- 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: main.cpp,v 1.12 2004/04/08 14:24:43 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.   Main of the rcssmonitor3D application   This is a very simple 3D monitor example which will hopefully be   used for the first steps of the 3D SoccerServer*//** This is a dummy agent created for testing with the SpadesTest. It    reads length prefixed data (see spades manual 6.3) from fd 3 and    writes to fd 4. A corresponding agent DB (agentdb.list, entry    'default') exists in the spadestest directory.*/#include <sstream>#include <zeitgeist/zeitgeist.h>#include <oxygen/oxygen.h>#include <soccer/soccertypes.h>#include "commserver.h"#include "behavior.h"#include "soccer.h"#include "kicknrun.h"#include "global.h"#include "worldmodel.h"using namespace zeitgeist;using namespace std;using namespace boost;using namespace oxygen;using namespace salt;// commserver instancestatic shared_ptr<CommServer> comm;// behavior instancestatic shared_ptr<Soccer> behave;// worldmodel instancestatic shared_ptr<WorldModel> wm;// set to 1 to write debug information to stdout#define ENABLE_LOGGING 1#ifdef ENABLE_LOGGINGvoidLog(const char* out){	DoLog(LOG_LOG, "%s",out);}#else#define Log(x)#endifvoidprintHelp(){    cout << "\nusage: agenttest [options]" << endl;    cout << "\noptions:" << endl;    cout << " --help      prints this message." << endl;    cout << " --teamname  sets the team name. " << endl;    cout << " --unum      sets the uniform number." << endl;    cout << "\n";}voidReadOptions(int argc, char* argv[]){    for( int i = 0; i < argc; i++)    {        if( strcmp( argv[i], "--teamname" ) == 0 )        {            if( i+1  < argc)            {                MyTeamName = argv[i+1];                ++i;                Log("setting teamname to ");                Log(MyTeamName.c_str());                Log("\n");            }        }        else if( strcmp( argv[i], "--help" ) == 0 )        {            printHelp();            exit(0);        } else if (strcmp( argv[i], "--unum" ) == 0 )        {            MyNumber = atoi(argv[i+1]);	    DoLog(LOG_PARSE, "******MyNumber=%d******" ,MyNumber);            ++i;            stringstream ss;            ss << "setting uniform number to " << MyNumber << "\n";            Log(ss.str().c_str());        }    }}intInit(int argc, char* argv[], Zeitgeist& zg){    // register agent classes    zg.GetCore()->RegisterClassObject(new CLASS(CommServer), "");    zg.GetCore()->RegisterClassObject(new CLASS(WorldModel), "");    zg.GetCore()->RegisterClassObject(new CLASS(KickNRun), "");    // run init script    zg.GetCore()->GetScriptServer()->RunInitScript("agenttest.rb", "app/agenttest");    // read command line options    ReadOptions(argc,argv);    // register and create the CommServer    comm = shared_dynamic_cast<CommServer>        (zg.GetCore()->Get("/sys/CommServer"));    if (comm.get() == 0)    {        Log("cannot find CommServer\n");        return 1;    }    // get the installed behavior    behave = shared_dynamic_cast<Soccer>        (zg.GetCore()->Get("sys/Behavior"));    if (behave.get() == 0)    {        Log("cannot find Behavior\n");        return 1;    }    // register and create the WorldModel    wm = shared_dynamic_cast<WorldModel>        (zg.GetCore()->Get("/sys/WorldModel"));    if (wm.get() == 0)    {        Log("cannot find WorldModel\n");        return 1;    }    behave->SetTeamName(MyTeamName);    wm->SetTeamName(MyTeamName);    behave->SetTeamUnum(MyNumber);    InitObjects();    return 0;}void Run(){    Log("AgentTest started\n");    while (true)    {        if (! comm->GetInput())        {            break;        }	//DoLog(LOG_GOALIE, "Msg von Server an Spieler: %s" ,comm->GetMsg());        wm->Parse(comm->GetMsg());	if(MyNumber == 0)	{		MyNumber = wm->GetTeamUnum();		logunit.Init(MyNumber);		if(MyNumber == 1)self.IsGoalie = true;		DoLog(LOG_PARSE,"MyNumber=[%d]",MyNumber);	}	if(TeamIndex == TI_NONE)	{		TeamIndex = wm->GetMyTeam();		if(TeamIndex != TI_NONE)			InitObjects();	}        switch(comm->GetMsg()[0])        {        case 'D' :            behave->ProcessInitMessage();            break;        case 'K' :            behave->ProcessThinkTimeMessage();            break;        case 'S' :            behave->Think();            break;        default:            Log("received unknown data: ");            Log(comm->GetMsg());            Log("\n");            break;        }    }}int main(int argc, char* argv[]){    //init zeitgeist and oxygen    Zeitgeist zg("." PACKAGE_NAME);    Oxygen oyxgen(zg);    int ret = Init(argc, argv, zg);    if (ret > 0)    {        return ret;    }    Run();}

⌨️ 快捷键说明

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