player_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_PLAYER_AGENT_H
00033 #define RCSC_PLAYER_AGENT_H
00034 
00035 #include <rcsc/player/world_model.h>
00036 #include <rcsc/player/action_effector.h>
00037 #include <rcsc/player/debug_client.h>
00038 #include <rcsc/player/player_config.h>
00039 #include <rcsc/player/see_state.h>
00040 #include <rcsc/common/soccer_agent.h>
00041 #include <rcsc/timer.h>
00042 #include <rcsc/types.h>
00043 
00044 #include <boost/scoped_ptr.hpp>
00045 #include <boost/shared_ptr.hpp>
00046 
00047 namespace rcsc {
00048 
00049 class DebugClient;
00050 class BodySensor;
00051 class VisualSensor;
00052 class AudioSensor;
00053 class FreeformParser;
00054 class FullstateSensor;
00055 class SeeState;
00056 class ArmAction;
00057 class NeckAction;
00058 class ViewAction;
00059 class SayMessage;
00060 class SayMessageParser;
00061 class SoccerIntention;
00062 
00063 struct PlayerAgentImpl;
00064 
00069 class PlayerAgent
00070     : public SoccerAgent {
00071 private:
00072 
00074     boost::scoped_ptr< PlayerAgentImpl > M_impl;
00075 
00076 protected:
00077 
00079     PlayerConfig M_config;
00080 
00082     DebugClient M_debug_client;
00083 
00085 
00087     WorldModel M_worldmodel;
00088 
00090     ActionEffector M_effector;
00091 
00092 public:
00096     PlayerAgent();
00097 
00101     virtual
00102     ~PlayerAgent();
00103 
00108     const
00109     PlayerConfig & config() const
00110       {
00111           return M_config;
00112       }
00113 
00118     DebugClient & debugClient()
00119       {
00120           return M_debug_client;
00121       }
00122 
00127     const
00128     WorldModel & world() const
00129       {
00130           return M_worldmodel;
00131       }
00132 
00137     const
00138     ActionEffector & effector() const
00139       {
00140           return M_effector;
00141       }
00142 
00147     const
00148     BodySensor & bodySensor() const;
00149 
00154     const
00155     VisualSensor & visualSensor() const;
00156 
00161     const
00162     AudioSensor & audioSensor() const;
00163 
00168     const
00169     FullstateSensor & fullstateSensor() const;
00170 
00175     const
00176     SeeState & seeState() const;
00177 
00182     const
00183     TimeStamp & bodyTimeStamp() const;
00184 
00189     const
00190     TimeStamp & seeTimeStamp() const;
00191 
00198     bool doKick( const double & power,
00199                  const AngleDeg & rel_dir );
00200 
00206     bool doDash( const double & power );
00207 
00213     bool doTurn( const AngleDeg & moment );
00214 
00219     bool doCatch();
00220 
00227     bool doMove( const double & x,
00228                  const double & y );
00229 
00235     bool doTackle( const double & power_or_dir );
00236 
00242     bool doTurnNeck( const AngleDeg & moment );
00243 
00251     bool doChangeView( const ViewWidth & width );
00252 
00258     //bool doSay( const std::string & msg );
00259 
00266     bool doPointto( const double & x,
00267                     const double & y );
00268 
00273     bool doPointtoOff();
00274 
00281     bool doAttentionto( SideID side,
00282                         const int unum );
00283 
00288     bool doAttentiontoOff();
00289 
00290 
00295     void setArmAction( ArmAction * act );
00296 
00301     void setNeckAction( NeckAction * act );
00302 
00307     void setViewAction( ViewAction * act );
00308 
00313     void addSayMessage( const SayMessage * message );
00314 
00320     bool removeSayMessage( const char header );
00321 
00327     void setIntention( SoccerIntention * intention );
00328 
00334     bool doIntention();
00335 
00336 protected:
00337 
00346     virtual
00347     bool initImpl( CmdLineParser & cmd_parser );
00348 
00357     virtual
00358     bool handleStart();
00359 
00366     virtual
00367     void handleMessage();
00368 
00376     virtual
00377     void handleTimeout( const int timeout_count,
00378                         const int waited_msec );
00379 
00383     virtual
00384     void handleExit();
00385 
00390     void addSayMessageParser( boost::shared_ptr< SayMessageParser > parser );
00391 
00396     void removeSayMessageParser( const char header );
00397 
00402     void setFreeformParser( boost::shared_ptr< FreeformParser > parser );
00403 
00404 public:
00408     void finalize();
00409 
00410 private:
00411 
00418     void sendInitCommand();
00419 
00424     void sendByeCommand();
00425 
00429     void setDebugFlags();
00430 
00432 
00437     void parse( const char * msg );
00438 
00448     bool analyzeCycle( const char * msg,
00449                        const bool by_sense_body );
00450 
00455     void analyzeSee( const char * msg );
00456 
00461     void analyzeSenseBody( const char * msg );
00462 
00467     void analyzeHear( const char * msg );
00468 
00473     void analyzeHearReferee( const char * msg );
00474 
00479     void analyzeHearPlayer( const char * msg );
00480 
00485     void analyzeHearOurCoach( const char * msg );
00486 
00491     void analyzeHearOpponentCoach( const char * msg );
00492 
00497     void analyzeHearTrainer( const char * msg );
00498 
00503     void analyzeFullstate( const char * msg );
00504 
00509     void analyzePlayerType( const char * msg );
00510 
00515     void analyzePlayerParam( const char * msg );
00516 
00521     void analyzeServerParam( const char * msg );
00522 
00527     void analyzeInit( const char * msg );
00528 
00533     void analyzeChangePlayerType( const char * msg );
00534 
00535 
00540     void analyzeScore( const char * msg );
00541 
00546     void analyzeOK( const char * msg );
00547 
00552     void analyzeError( const char * msg );
00553 
00558     void analyzeWarning( const char * msg );
00559 
00561 
00565     void action();
00566 
00572     void doArmAction();
00573 
00580     void doViewAction();
00581 
00587     void doNeckAction();
00588 
00590 
00597     void adjustSeeSynchNormalMode();
00598 
00608     void adjustSeeSynchSynchMode();
00609 
00610 protected:
00611 
00619     virtual
00620     void actionImpl() = 0;
00621 
00629     virtual
00630     void communicationImpl()
00631       { }
00632 
00639     virtual
00640     void outputDebug();
00641 
00645     virtual
00646     void handleServerParam()
00647       { }
00648 
00652     virtual
00653     void handlePlayerParam()
00654       { }
00655 
00659     virtual
00660     void handlePlayerType()
00661       { }
00662 };
00663 
00664 }
00665 
00666 #endif

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