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

📄 main.cpp

📁 agentspark 机器人模拟代码 适用robocup 机器人步态模拟仿真(机器人动作在NAOGETUP.cpp下修改)
💻 CPP
字号:
/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
   this file is part of rcssserver3D
   Fri May 9 2003
   Copyright (C) 2003 Koblenz University
   $Id: main.cpp,v 1.15 2008/04/10 14:20:19 fengxue 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.
*/

#include <string>
#include <iostream>
#include <errno.h>
#include <signal.h>
#include <stdlib.h>

#include "./Utilities/StaticModule.h"
#include "Net.h"
#include "Parser.h"

#include "./WorldModel/worldmodel.h"
#include "./WorldModel/ball.h"
#include "./WorldModel/self.h"
#include "./WorldModel/fieldinfo.h"
#include "types.h"

#include "./RobotModel/robot.h"
#include "./RobotModel/nao.h"
#include "./RobotModel/soccerbot.h"

#include "./Action/NaoGetUp.h"
#include "./Action/behavior.h"
#include "./Action/tactic.h"


using namespace std;
using namespace boost;

// bool to indicate whether to continue the agent mainloop
static bool gLoop = true;

// SIGINT handler prototype
extern "C" void handler ( int sig )
{
	if ( sig == SIGINT )
		gLoop = false;
}

void PrintGreeting()
{
	cout << "Copyright (C) 2008 Neil Zhu,Yonglei Zheng.\n"
	        << "2008 RoboCup Soccer 3D Simulation--Strive3D.\n\n";
}

void PrintHelp()
{
	cout << "\nusage: Strive3D [options]" << endl;
	cout << "\noptions:" << endl;
	cout << " --help      prints this message." << endl;
	cout << " --host=IP   IP of the server." << endl;
	cout << "\n";
}

void initStaticModules()
{    /*
	//Logger must be the very first to initialized.
	StaticModule<Logger>::init();
	StaticModule<Logger>::getInstance().add("MainLog", new LogFile("./MainLog.log"));
	StaticModule<Logger>::getInstance().add("ParserLog", new LogFile("./ParserLog.log"));
	StaticModule<Logger>::getInstance().add("ActionLog", new LogFile("./ActionLog.log"));
	//LOG is defined as StaticModule<Logger>::getInstance()["MainLog"]
	LOG.newCycle(0);
	pLOG.newCycle(0);*/
	//Connection
	StaticModule<Net>::init(); //Initialize connection
	//Parser
	StaticModule<Parser>::init(); //Initialize connection
	//RobotModel
	StaticModule<Nao>::init(); 
	StaticModule<Soccerbot>::init();
	//Action
	StaticModule<Tactic>::init();
	StaticModule<Behavior>::init();
 	StaticModule<NaoGetUp>::init();

	
	//WorldModel
	StaticModule<Self>::init();
	StaticModule<Ball>::init();
	StaticModule<FieldInfo>::init();
	StaticModule<WorldModel>::init(); //Initialize World Model


	cout<<"initStaticModules-->All static modules are initialized."<<endl;
}
int main ( int argc, char* argv[] )
{	initStaticModules();
	bool mInit = false;
	// registering the handler, catching SIGINT signals
	signal ( SIGINT, handler );

	PrintGreeting();
	
	for ( int i = 0; i < argc; i++ )
	{
		if ( strcmp ( argv[i], "--help" ) == 0 )
		{
			PrintHelp();
			exit ( 0 );
		}
		else if ( strncmp ( argv[i], "--host", 6 ) == 0 )
		{
			string tmp=argv[i];

			if ( tmp.length() <= 7 ) // minimal sanity check
			{
				PrintHelp();
				exit ( 0 );
			}
			NET.SetServer( tmp.substr ( 7 ));
		}


	}

	if ( ! NET.Init() )
	{
		return 1;
	}
	
	cout<< "Hi Neil"<<endl;
	NET.PutMessage( BEHAVIOR->InitRobot() );

	string msg;
	while ( gLoop )
	{
		NET.GetMessage ( msg );
		//LOG <<"(currentcycle: " << SELF.CurrentCycle << ")  "<< msg << endl;
		//LOG << "*******************************Message End***************************************" << endl;
		//PARSER.parseAll(msg);
		if (! mInit)
    		{
        		mInit = true;
        		NET.PutMessage( BEHAVIOR->InitAgent() ) ;
				FIELDINFO.Init();
				WM.Init();

			NAOGETUP->Init();

    		}
			NET.PutMessage( BEHAVIOR->Think( msg ));
	}
	NET.Done();
}

⌨️ 快捷键说明

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