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

📄 trainer.h

📁 RoboCup 3D 仿真组清华大学2005的源代码
💻 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 TRAINER_H#define TRAINER_H#include <soccer/soccertypes.h>#include <zeitgeist/leaf.h>#include "logserver.h"class Trainer{public:    Trainer();    ~Trainer();    bool IsConnected();    bool Connect(const char* ip);        void KickOff()    {        send_command("(kickoff)");     }        void DropBall()    {        send_command("(dropBall)");     }    void SetPlayMode(TPlayMode mode)    {        char s[1024];        if(mode == PM_BeforeKickOff) strcpy(s, STR_PM_BeforeKickOff);        else if(mode == PM_KickOff_Left) strcpy(s, STR_PM_KickOff_Left);        else if(mode == PM_KickOff_Right) strcpy(s, STR_PM_KickOff_Right);        else if(mode == PM_PlayOn) strcpy(s, STR_PM_PlayOn);        else if(mode == PM_KickIn_Left) strcpy(s, STR_PM_KickIn_Left);        else if(mode == PM_KickIn_Right) strcpy(s, STR_PM_KickIn_Right);        else if(mode == PM_Goal_Left) strcpy(s, STR_PM_Goal_Left);        else if(mode == PM_Goal_Right) strcpy(s, STR_PM_Goal_Right);        else if(mode == PM_GameOver) strcpy(s, STR_PM_GameOver);        else if(mode == PM_CORNER_KICK_LEFT) strcpy(s, STR_PM_CORNER_KICK_LEFT);        else if(mode == PM_CORNER_KICK_RIGHT) strcpy(s, STR_PM_CORNER_KICK_RIGHT);        else if(mode == PM_GOAL_KICK_LEFT) strcpy(s, STR_PM_GOAL_KICK_LEFT);        else if(mode == PM_GOAL_KICK_RIGHT) strcpy(s, STR_PM_GOAL_KICK_RIGHT);        SetPlayMode(s);    }        void SetPlayMode(const char* str)    {        char s[1024];        sprintf(s, "(playMode %s)", str);        send_command(s);    }        // team = 1~2, unum = 1~11    void SetAgentStatus(int team, int unum, salt::Vector3f pos, salt::Vector3f vel)    {        char s[1024];        sprintf(s, "(agent (team %s) (unum %d) (pos %.3f %.3f %.3f) (vel %.3f %.3f %.3f))",                 team==1?"L":"R", unum, pos[0], pos[1], pos[2], vel[0], vel[1], vel[2]);         send_command(s);    }        void SetBallStatus(salt::Vector3f pos, salt::Vector3f vel)    {        char s[1024];        sprintf(s, "(ball (pos %.3f %.3f %.3f) (vel %.3f %.3f %.3f))",                 pos[0], pos[1], pos[2], vel[0], vel[1], vel[2]);        send_command(s);    }        void SetBallVel(salt::Vector3f vel)    {        char s[1024];        sprintf(s, "(ball (vel %.3f %.3f %.3f))", vel[0], vel[1], vel[2]);        send_command(s);    }protected:    int sock;    bool match(const char* data);    bool get_data(char* data);    bool send_data(const char* data);    void send_command(const char* str);       bool mConnected;    public:        LogServer log;};#endif

⌨️ 快捷键说明

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