00001
00002
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00031
00032 #ifndef RCSC_COACH_COACH_AGENT_H
00033 #define RCSC_COACH_COACH_AGENT_H
00034
00035 #include <rcsc/coach/global_world_model.h>
00036 #include <rcsc/coach/coach_config.h>
00037 #include <rcsc/common/soccer_agent.h>
00038 #include <rcsc/common/team_graphic.h>
00039
00040 #include <boost/scoped_ptr.hpp>
00041
00042 #include <string>
00043 #include <set>
00044
00045 namespace rcsc {
00046
00047 class CoachAudioSensor;
00048 class CoachCommand;
00049 class GlobalVisualSensor;
00050 class SayMessageParser;
00051
00052 struct CoachAgentImpl;
00053
00058 class CoachAgent
00059 : public SoccerAgent {
00060 private:
00061
00063 boost::scoped_ptr< CoachAgentImpl > M_impl;
00064
00065 protected:
00066
00068 CoachConfig M_config;
00069
00071 GlobalWorldModel M_worldmodel;
00072
00073 private:
00074
00076 std::set< TeamGraphic::Index > M_team_graphic_ok_set;
00077
00078 public:
00082 CoachAgent();
00086 virtual
00087 ~CoachAgent();
00088
00093 const
00094 CoachConfig & config() const
00095 {
00096 return M_config;
00097 }
00098
00103 const
00104 GlobalWorldModel & world() const
00105 {
00106 return M_worldmodel;
00107 }
00108
00113 const
00114 GlobalVisualSensor & visualSensor() const;
00115
00120 const
00121 CoachAudioSensor & audioSensor() const;
00122
00127 const
00128 std::set< TeamGraphic::Index > & teamGraphicOKSet() const
00129 {
00130 return M_team_graphic_ok_set;
00131 }
00132
00133 protected:
00143 virtual
00144 bool initImpl( CmdLineParser & cmd_parser );
00145
00154 virtual
00155 bool handleStart();
00156
00162 virtual
00163 void handleMessage();
00164
00173 virtual
00174 void handleTimeout( const int timeout_count,
00175 const int waited_msec );
00176
00180 virtual
00181 void handleExit();
00182
00187 void addSayMessageParser( boost::shared_ptr< SayMessageParser > parser );
00188
00193 void removeSayMessageParser( const char header );
00194
00195 public:
00199 void finalize();
00200
00201 private:
00202
00209 void sendInitCommand();
00210
00215 void sendByeCommand();
00216
00218
00223 void parse( const char * msg );
00224
00229 void analyzeInit( const char * msg );
00230
00237 bool analyzeCycle( const char * msg,
00238 const bool by_see_global );
00239
00244 void analyzeSeeGlobal( const char * msg );
00245
00250 void analyzeHear( const char * msg );
00251
00256 void analyzeHearReferee( const char * msg );
00257
00262 void analyzeHearPlayer( const char * msg );
00263
00268 void analyzeChangePlayerType( const char * msg );
00269
00274 void analyzePlayerType( const char * msg );
00275
00280 void analyzePlayerParam( const char * msg );
00281
00286 void analyzeServerParam( const char * msg );
00287
00292 void analyzeCLangVer( const char * msg );
00293
00298 void analyzeScore( const char * msg );
00299
00304 void analyzeOK( const char * msg );
00305
00310 void analyzeOKTeamGraphic( const char * msg );
00311
00316 void analyzeTeamNames( const char * msg );
00317
00322 void analyzeError( const char * msg );
00323
00328 void analyzeWarning( const char * msg );
00329
00334 void analyzeInclude( const char * msg );
00335
00339 void action();
00340
00346 bool sendCommand( const CoachCommand & com );
00347
00348 public:
00353 bool doCheckBall();
00354
00359 bool doLook();
00360
00365 bool doTeamNames();
00366
00367
00368
00374 bool doEye( bool on );
00375
00382 bool doChangePlayerType( const int unum,
00383 const int type );
00384
00390 bool doChangePlayerTypes( const std::vector< std::pair< int, int > > & types );
00391
00396 bool doSayFreeform( const std::string & msg );
00397
00398
00399
00400
00405 bool doTeamGraphic( const int x,
00406 const int y,
00407 const TeamGraphic & team_graphic );
00408
00409 protected:
00410
00418 virtual
00419 void actionImpl() = 0;
00420 };
00421
00422 }
00423
00424 #endif