📄 soccercommand.cpp
字号:
/*************************************************************************** * Copyright (C) 2004 - 2006 by ZJUBase *
* National Lab of Industrial Control Tech. * * Zhejiang University, China * * * * Achievements of ZJUBase in RoboCup Soccer 3D Simulation League: *
* In RoboCup championship, *
* - June 2006 - 3rd place in RoboCup 2006, Bremen, Germany (lost * * the semi-final with a coin toss) *
* - July 2005 - 3rd place in RoboCup 2005, Osaka, Japan (share the * * 3rd place with team Caspian) *
* In RoboCup local events, *
* - April 2006 - 2nd place in RoboCup Iran Open 2006, Tehran, Iran * * (lost the final with a coin toss) *
* - December 2005 - 2nd place in AI Games 2005, Isfahan, Iran *
* - July 2005 - champion in China Robot Competition 2005, Changzhou, * * China *
* - October 2004 - champion in China Soccer Robot Competition 2004, * * Guangzhou, China *
* * * Team members: *
* Currently the team leader is, * * Hao JIANG (jianghao@iipc.zju.edu.cn; riveria@gmail.com) *
* In the next season, the leader will be * * Yifeng ZHANG (yfzhang@iipc.zju.edu.cn) *
* ZJUBase 3D agent is created by * * Dijun LUO (djluo@iipc.zju.edu.cn) *
* All the members who has ever contributed: * * Jun JIANG *
* Xinfeng DU (xfdu@iipc.zju.edu.cn) *
* Yang ZHOU (yzhou@iipc.zju.edu.cn) *
* Zhipeng YANG *
* Xiang FAN *
* *
* Team Manager: *
* Ms. Rong XIONG (rxiong@iipc.zju.edu.cn) *
* *
* If you met any problems or you have something to discuss about * * ZJUBase. Please feel free to contact us through EMails given below. * * * * 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. * ***************************************************************************/#include "Global.h"
#include "SoccerCommand.h"
#include "worldmodel.h"
SoccerCommand::SoccerCommand()
{}
SoccerCommand::~SoccerCommand()
{}
SoccerCommand::SoccerCommand(CMDType cmdType, Vector3 value)
{ ct = cmdType; switch(cmdType){ case CT_BEAM: case CT_DRIVE: vvalue[0] = value; break; default: ct = CT_NONE; }}
SoccerCommand::SoccerCommand(CMDType cmdType, Vector3 value1, double value2) //drive direction power
{ ct = cmdType; double mod = value1.mod(); if(mod<0.0001) mod = 0.0001; Vector3 driver = value1 / mod; driver = Vector3(driver.x*value2,driver.y*value2,value1.z);
switch(cmdType){ case CT_BEAM: case CT_DRIVE: vvalue[0] = driver; break; default: ct = CT_NONE; }}
SoccerCommand::SoccerCommand(CMDType cmdType,double value1,double value2)
{ ct = cmdType; switch(cmdType){ case CT_KICK: dvalue[0] = value1;//angle dvalue[1] = value2;//power break; case CT_PANTILT: dvalue[0] = value1; //pan_angle dvalue[1] = value2; //tilt_angle break; default: ct = CT_NONE; }}
SoccerCommand::SoccerCommand(CMDType cmdType, char *MSG){ ct = CT_SAY; switch (cmdType){ case CT_SAY: strcpy(sayMSG, MSG); break; default: ct = CT_NONE; }}
char* SoccerCommand::getCommandString()
{#ifdef WIN32 Vector3 ppp;#endif
switch(ct){ case CT_NONE: strCMD[0] = '\0'; break;
case CT_CREATE_AGENT: sprintf(strCMD,"A(create)"); break;
case CT_INIT_AGENT: sprintf(strCMD,"A(init (unum %d) (teamname %s))",0,global.strTeamName); break;
case CT_DRIVE: #ifdef WIN32 ppp=global.wm.nextPos+vvalue[0]*0.02;// ShowLine(global.wm.nextPos,ppp,"128 0 128 F_(%3.1f_%3.1f_%3.1f)",vvalue[0].x,vvalue[0].y,vvalue[0].z);#endif sprintf(strCMD,"A(drive %3.3f %3.3f %3.3f)",vvalue[0].x,vvalue[0].y,vvalue[0].z); break;
case CT_KICK: sprintf(strCMD,"A(kick %3.3f %3.3f)",dvalue[0],dvalue[1]); break;
case CT_BEAM: sprintf(strCMD,"A(beam %3.3f %3.3f %3.3f)",vvalue[0].x,vvalue[0].y,vvalue[0].z); break;
case CT_PANTILT: sprintf(strCMD,"A(pantilt %3.3f %3.3f)",dvalue[0],dvalue[1]); global.wm.myPanAngle=Normalize(global.wm.myPanAngle+dvalue[0]); break;
case CT_CATCH: sprintf(strCMD,"A(catch)"); break;
case CT_SAY: sprintf(strCMD, "A(say %s)", sayMSG); break;
default: break; }
return strCMD;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -