trainer_agent.h

説明を見る。
00001 // -*-c++-*-
00002 
00008 /*
00009  *Copyright:
00010 
00011  Copyright (C) Hidehisa AKIYAMA
00012 
00013  This code is free software; you can redistribute it and/or
00014  modify it under the terms of the GNU Lesser General Public
00015  License as published by the Free Software Foundation; either
00016  version 2.1 of the License, or (at your option) any later version.
00017 
00018  This library is distributed in the hope that it will be useful,
00019  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  Lesser General Public License for more details.
00022 
00023  You should have received a copy of the GNU Lesser General Public
00024  License along with this library; if not, write to the Free Software
00025  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 
00027  *EndCopyright:
00028  */
00029 
00031 
00032 #ifndef RCSC_TRAINER_TRAINER_AGENT_H
00033 #define RCSC_TRAINER_TRAINER_AGENT_H
00034 
00035 #include <rcsc/trainer/trainer_config.h>
00036 #include <rcsc/coach/global_world_model.h>
00037 #include <rcsc/common/soccer_agent.h>
00038 #include <rcsc/geom/vector_2d.h>
00039 #include <rcsc/types.h>
00040 
00041 #include <boost/scoped_ptr.hpp>
00042 
00043 #include <string>
00044 
00045 namespace rcsc {
00046 
00047 struct TrainerAgentImpl;
00048 class TrainerCommand;
00049 class GlobalVisualSensor;
00050 
00055 class TrainerAgent
00056     : public SoccerAgent {
00057 private:
00058 
00060     boost::scoped_ptr< TrainerAgentImpl > M_impl;
00061 
00062 protected:
00063 
00065     TrainerConfig M_config;
00066 
00068     GlobalWorldModel M_worldmodel;
00069 
00070 public:
00074     TrainerAgent();
00075 
00079     virtual
00080     ~TrainerAgent();
00081 
00086     const
00087     TrainerConfig & config() const
00088       {
00089           return M_config;
00090       }
00091 
00096     const
00097     GlobalWorldModel & world() const
00098       {
00099           return M_worldmodel;
00100       }
00101 
00106     const
00107     GlobalVisualSensor & visualSensor() const;
00108 
00109 protected:
00119     virtual
00120     bool initImpl( CmdLineParser & cmd_parser );
00121 
00130     virtual
00131     bool handleStart();
00132 
00138     virtual
00139     void handleMessage();
00140 
00149     virtual
00150     void handleTimeout( const int timeout_count,
00151                         const int waited_msec );
00152 
00156     virtual
00157     void handleExit();
00158 
00159 public:
00163     void finalize();
00164 
00165 private:
00166 
00173     void sendInitCommand();
00174 
00179     void sendByeCommand();
00180 
00182 
00187     void parse( const char * msg );
00188 
00193     void analyzeInit( const char * msg );
00194 
00200     bool analyzeCycle( const char * msg,
00201                        const bool by_see_global );
00202 
00207     void analyzeSeeGlobal( const char * msg );
00208 
00213     void analyzeHear( const char * msg );
00214 
00219     void analyzeHearReferee( const char * msg );
00220 
00225     void analyzeHearPlayer( const char * msg );
00226 
00231     void analyzeChangePlayerType( const char * msg );
00232 
00237     void analyzePlayerType( const char * msg );
00238 
00243     void analyzePlayerParam( const char * msg );
00244 
00249     void analyzeServerParam( const char * msg );
00250 
00255     void analyzeOK( const char * msg );
00256 
00261     void analyzeTeamNames( const char * msg );
00262 
00267     void analyzeError( const char * msg );
00268 
00273     void analyzeWarning( const char * msg );
00274 
00275 
00279     void action();
00280 
00286     bool sendCommand( const TrainerCommand & com );
00287 
00288 public:
00289 
00294     bool doCheckBall();
00295 
00300     bool doLook();
00301 
00306     bool doTeamNames();
00307 
00313     bool doEye( bool on );
00314 
00320     bool doEar( bool on );
00321 
00326     bool doKickOff();
00327 
00334     bool doMoveBall( const Vector2D & pos,
00335                      const Vector2D & vel );
00336 
00344     bool doMovePlayer( const std::string & teamname,
00345                        const int unum,
00346                        const Vector2D & pos );
00347 
00356     bool doMovePlayer( const std::string & teamname,
00357                        const int unum,
00358                        const Vector2D & pos,
00359                        const AngleDeg & angle );
00360 
00365     bool doRecover();
00366 
00372     bool doChangeMode( const PlayMode mode );
00373 
00381     bool doChangePlayerType( const std::string & teamname,
00382                              const int unum,
00383                              const int type );
00384 
00389     bool doSay( const std::string & msg );
00390 
00391 protected:
00392 
00400     virtual
00401     void actionImpl() = 0;
00402 };
00403 
00404 }
00405 
00406 #endif

librcscに対してThu May 1 15:41:22 2008に生成されました。  doxygen 1.5.0