LIBRCSC Docs
Documentation for HELIOS's BASE LIBRCSC library for RoboCup 2D Simulation League.
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rcsc::PlayerAgent Class Referenceabstract

basic player agent class More...

#include <player_agent.h>

Inheritance diagram for rcsc::PlayerAgent:
Inheritance graph
[legend]
Collaboration diagram for rcsc::PlayerAgent:
Collaboration graph
[legend]

Public Member Functions

 PlayerAgent ()
 create internal modules
 
virtual ~PlayerAgent ()
 virtual destructor
 
virtual std::shared_ptr< AbstractClientcreateConsoleClient ()
 create a client object (online or offline) according to the command line option. More...
 
void finalize ()
 finalize all things when the process exits
 
const PlayerConfigconfig () const
 get configuration set More...
 
DebugClientdebugClient ()
 get debug client interface More...
 
const WorldModelworld () const
 get worldmodel More...
 
const WorldModelfullstateWorld () const
 get fullstate worldmodel More...
 
const ActionEffectoreffector () const
 get action effector More...
 
const BodySensorbodySensor () const
 get body sensor More...
 
const VisualSensorvisualSensor () const
 get visual sensor More...
 
const AudioSensoraudioSensor () const
 get audio sensor More...
 
const FullstateSensorfullstateSensor () const
 get fullstate sensor More...
 
const SeeStateseeState () const
 get see state More...
 
const TimeStampbodyTimeStamp () const
 get time stamp when sense_body message is received More...
 
const TimeStampseeTimeStamp () const
 get time stamp of see message when see message is received More...
 
bool doKick (const double &power, const AngleDeg &rel_dir)
 register kick command More...
 
bool doDash (const double &power, const AngleDeg &rel_dir=0.0)
 register dash command More...
 
bool doTurn (const AngleDeg &moment)
 register turn command More...
 
bool doCatch ()
 register catch command. catch direction is automatically calculated. More...
 
bool doMove (const double &x, const double &y)
 register move command More...
 
bool doTackle (const double &power_or_dir, const bool foul=false)
 register tackle command More...
 
bool doTurnNeck (const AngleDeg &moment)
 register turn_neck command. More...
 
bool doChangeView (const ViewWidth &width)
 register change_view command. More...
 
bool doChangeFocus (const double moment_dist, const AngleDeg &moment_dir)
 register change_focus command More...
 
bool doPointto (const double &x, const double &y)
 register pointto command. More...
 
bool doPointtoOff ()
 register pointto command. turn off mode More...
 
bool doAttentionto (SideID side, const int unum)
 register attentionto command by off mode More...
 
bool doAttentiontoOff ()
 register attentionto command. turn off mode More...
 
void setArmAction (ArmAction *act)
 reserve pointto action More...
 
void setNeckAction (NeckAction *act)
 reserve turn neck action More...
 
void setViewAction (ViewAction *act)
 reserve change view action More...
 
void setFocusAction (FocusAction *act)
 reserve change_focus action More...
 
void addSayMessage (SayMessage *message)
 add say message to the action effector More...
 
bool removeSayMessage (const char header)
 remove the registered say message if exist More...
 
void clearSayMessage ()
 remove all registered say messages
 
void setIntention (SoccerIntention *intention)
 set intention object More...
 
bool doIntention ()
 execute queued intention if exist. More...
 
- Public Member Functions inherited from rcsc::SoccerAgent
 SoccerAgent ()
 nothing to do. just set NULL to M_client
 
virtual ~SoccerAgent ()
 virtual destructor.
 
bool init (CmdLineParser &cmd_parser)
 initialize with command line options. More...
 
void setClient (std::shared_ptr< AbstractClient > client)
 
virtual std::shared_ptr< AbstractClientcreateConsoleClient ()=0
 create standard console client object (online or offline) according to the command line option. More...
 

Protected Member Functions

virtual bool initImpl (CmdLineParser &cmd_parser)
 analyze command line options More...
 
virtual bool handleStart ()
 handle start event More...
 
virtual bool handleStartOffline ()
 handle start event in offline client mode. More...
 
virtual void handleMessage ()
 handle server message event More...
 
virtual void handleMessageOffline ()
 handle offline client log message in offline client mode. More...
 
virtual void handleTimeout (const int timeout_count, const int waited_msec)
 handle timeout event More...
 
virtual void handleExit ()
 handle exit event More...
 
virtual void actionImpl ()=0
 pure virtual method. register body action to ActionEffector. More...
 
virtual void communicationImpl ()
 virtual method. register say action to ActionEffector More...
 
virtual void handleActionStart ()
 This method is called at the top of action(). Do not call this method by yourself.
 
virtual void handleActionEnd ()
 This method is called at the end of action() but before the debug output. Do not call this method by yourself.
 
virtual void handleInitMessage ()
 this method is called just after analyzing init message. Do not call this method by yourself.
 
virtual void handleServerParam ()
 this method is called just after analyzing server_param message. Do not call this method by yourself.
 
virtual void handlePlayerParam ()
 this method is called just after analyzing player_param message. Do not call this method by yourself.
 
virtual void handlePlayerType ()
 this method is called just after analyzing player_type message. Do not call this method by yourself.
 
virtual void handleOnlineCoachAudio ()
 this method is called just after analyzing online coach's say message. Do not call this method by yourself.
 
void addSayMessageParser (SayMessageParser *parser)
 register new say message parser object More...
 
void removeSayMessageParser (const char header)
 remove registered parser object More...
 
void addFreeformMessageParser (FreeformMessageParser *parser)
 set new freeform message parser More...
 
void removeFreeformMessageParser (const std::string &type)
 remove registered parser object More...
 
virtual bool initImpl (CmdLineParser &cmd_parser)=0
 init interval status using command line options More...
 
virtual bool handleStart ()=0
 (pure virtual) handle start event More...
 
virtual bool handleStartOffline ()
 (virtual) handle start event in offline client mode. More...
 
virtual void handleMessage ()=0
 (pure virtual) handle server messege More...
 
virtual void handleMessageOffline ()
 (virtual) handle offline client log message in offline client mode. More...
 
virtual void handleTimeout (const int timeout_count, const int waited_msec)=0
 (pure virtual) handle timeout event More...
 
virtual void handleExit ()=0
 (pure virtual) handle exit event More...
 

Protected Attributes

PlayerConfig M_config
 configuration parameter set
 
DebugClient M_debug_client
 debug client interface
 
WorldModel M_worldmodel
 mental memory of world status
 
WorldModel M_fullstate_worldmodel
 mental memory of fullstate world status
 
ActionEffector M_effector
 action info manager
 
- Protected Attributes inherited from rcsc::SoccerAgent
std::shared_ptr< AbstractClientM_client
 interface to the rcssserver or offline log.
 

Detailed Description

basic player agent class

Member Function Documentation

◆ actionImpl()

virtual void rcsc::PlayerAgent::actionImpl ( )
protectedpure virtual

pure virtual method. register body action to ActionEffector.

This method is used to set player's body action. Do not call this method by yourself because this method is called automatically.

◆ addFreeformMessageParser()

void rcsc::PlayerAgent::addFreeformMessageParser ( FreeformMessageParser parser)
protected

set new freeform message parser

Parameters
parserpointer to the dynamically allocated parser object.

◆ addSayMessage()

void rcsc::PlayerAgent::addSayMessage ( SayMessage message)

add say message to the action effector

Parameters
messagepointer to the dynamically allocated object.

◆ addSayMessageParser()

void rcsc::PlayerAgent::addSayMessageParser ( SayMessageParser parser)
protected

register new say message parser object

Parameters
parserpointer to the dynamically allocated parser object.

◆ audioSensor()

const AudioSensor & rcsc::PlayerAgent::audioSensor ( ) const

get audio sensor

Returns
const reference to the audio sensor instance

◆ bodySensor()

const BodySensor & rcsc::PlayerAgent::bodySensor ( ) const

get body sensor

Returns
const reference to the body sensor instance

◆ bodyTimeStamp()

const TimeStamp & rcsc::PlayerAgent::bodyTimeStamp ( ) const

get time stamp when sense_body message is received

Returns
const reference to the time stamp object

◆ communicationImpl()

virtual void rcsc::PlayerAgent::communicationImpl ( )
inlineprotectedvirtual

virtual method. register say action to ActionEffector

This method is called just after turn_neck action. Do not call this method by yourself because this method is called automatically.

◆ config()

const PlayerConfig & rcsc::PlayerAgent::config ( ) const
inline

get configuration set

Returns
const reference to the configuration class object

◆ createConsoleClient()

virtual std::shared_ptr< AbstractClient > rcsc::PlayerAgent::createConsoleClient ( )
virtual

create a client object (online or offline) according to the command line option.

Returns
client object pointer.

Implements rcsc::SoccerAgent.

◆ debugClient()

DebugClient & rcsc::PlayerAgent::debugClient ( )
inline

get debug client interface

Returns
reference to the DebugClient object

◆ doAttentionto()

bool rcsc::PlayerAgent::doAttentionto ( SideID  side,
const int  unum 
)

register attentionto command by off mode

Parameters
sidetarget player's side
unumtarget player's uniform number
Returns
true if successfully registered.

◆ doAttentiontoOff()

bool rcsc::PlayerAgent::doAttentiontoOff ( )

register attentionto command. turn off mode

Returns
true if successfully registered.

◆ doCatch()

bool rcsc::PlayerAgent::doCatch ( )

register catch command. catch direction is automatically calculated.

Returns
true if successfully registered.

◆ doChangeFocus()

bool rcsc::PlayerAgent::doChangeFocus ( const double  moment_dist,
const AngleDeg moment_dir 
)

register change_focus command

Parameters
moment_distdistance added to the current focus point
moment_dirdirection added to the current focus point

◆ doChangeView()

bool rcsc::PlayerAgent::doChangeView ( const ViewWidth width)

register change_view command.

Parameters
widthnew view width
Returns
true if successfully registered.

ViewQuality should not be changed by user

◆ doDash()

bool rcsc::PlayerAgent::doDash ( const double &  power,
const AngleDeg rel_dir = 0.0 
)

register dash command

Parameters
powercommand argument: dash power
rel_dircommand argument: dash direction relative to body (or reverse body) angle
Returns
true if successfully registered.

◆ doIntention()

bool rcsc::PlayerAgent::doIntention ( )

execute queued intention if exist.

Return values
trueif action is executed
falseif queue is empty, or action is failed.

◆ doKick()

bool rcsc::PlayerAgent::doKick ( const double &  power,
const AngleDeg rel_dir 
)

register kick command

Parameters
powercommand argument: kick power
rel_dircommand argument kick direction relative to body angle
Returns
true if successfully registered.

◆ doMove()

bool rcsc::PlayerAgent::doMove ( const double &  x,
const double &  y 
)

register move command

Parameters
xmove target x
ymove target y
Returns
true if successfully registered.

◆ doPointto()

bool rcsc::PlayerAgent::doPointto ( const double &  x,
const double &  y 
)

register pointto command.

Parameters
xtarget point x
ytarget point y
Returns
true if successfully registered.

◆ doPointtoOff()

bool rcsc::PlayerAgent::doPointtoOff ( )

register pointto command. turn off mode

Returns
true if successfully registered.

◆ doTackle()

bool rcsc::PlayerAgent::doTackle ( const double &  power_or_dir,
const bool  foul = false 
)

register tackle command

Parameters
power_or_dirtackle power or direction
foulfoul mode switch
Returns
true if successfully registered.

◆ doTurn()

bool rcsc::PlayerAgent::doTurn ( const AngleDeg moment)

register turn command

Parameters
momentcommand argument: turn moment
Returns
true if successfully registered.

◆ doTurnNeck()

bool rcsc::PlayerAgent::doTurnNeck ( const AngleDeg moment)

register turn_neck command.

Parameters
momentturn neck moment
Returns
true if successfully registered.

◆ effector()

const ActionEffector & rcsc::PlayerAgent::effector ( ) const
inline

get action effector

Returns
reference to action effector

◆ fullstateSensor()

const FullstateSensor & rcsc::PlayerAgent::fullstateSensor ( ) const

get fullstate sensor

Returns
const reference to the fullstate sensor instance

◆ fullstateWorld()

const WorldModel & rcsc::PlayerAgent::fullstateWorld ( ) const
inline

get fullstate worldmodel

Returns
const reference to fullstate world model instance

◆ handleExit()

virtual void rcsc::PlayerAgent::handleExit ( )
protectedvirtual

handle exit event

Implements rcsc::SoccerAgent.

◆ handleMessage()

virtual void rcsc::PlayerAgent::handleMessage ( )
protectedvirtual

handle server message event

This method is called from AbstractClient::run() method. Do NOT call this method by yourself!

Implements rcsc::SoccerAgent.

◆ handleMessageOffline()

virtual void rcsc::PlayerAgent::handleMessageOffline ( )
protectedvirtual

handle offline client log message in offline client mode.

This method is called when offline client log message is read.

Reimplemented from rcsc::SoccerAgent.

◆ handleStart()

virtual bool rcsc::PlayerAgent::handleStart ( )
protectedvirtual

handle start event

Returns
status of start procedure.

This method is called when client starts to run. The concrete agent must connect to the server and send init command. Do NOT call this method by yourself!

Implements rcsc::SoccerAgent.

◆ handleStartOffline()

virtual bool rcsc::PlayerAgent::handleStartOffline ( )
protectedvirtual

handle start event in offline client mode.

Returns
status of start procedure.

This method is called at the top of AbstractClient::run() method. The concrete agent must connect to the server and send init command. Do NOT call this method by yourself!

Reimplemented from rcsc::SoccerAgent.

◆ handleTimeout()

virtual void rcsc::PlayerAgent::handleTimeout ( const int  timeout_count,
const int  waited_msec 
)
protectedvirtual

handle timeout event

Parameters
timeout_countcount of timeout without sensory message.
waited_msecelapsed milliseconds since last sensory message. This method is called from AbstractClient::run() method. Do NOT call this method by yourself!

Implements rcsc::SoccerAgent.

◆ initImpl()

virtual bool rcsc::PlayerAgent::initImpl ( CmdLineParser cmd_parser)
protectedvirtual

analyze command line options

Parameters
cmd_parsercommand line parser object
Returns
false only if "help" option is given, othewise true.

This method is called from SoccerAgent::init( argc, argv ) SoccerAgent::init(argc,argv) should be called in main().

Implements rcsc::SoccerAgent.

◆ removeFreeformMessageParser()

void rcsc::PlayerAgent::removeFreeformMessageParser ( const std::string &  type)
protected

remove registered parser object

Parameters
typefreeform message type string

◆ removeSayMessage()

bool rcsc::PlayerAgent::removeSayMessage ( const char  header)

remove the registered say message if exist

Parameters
headermessage header character
Returns
true if removed

◆ removeSayMessageParser()

void rcsc::PlayerAgent::removeSayMessageParser ( const char  header)
protected

remove registered parser object

Parameters
headersay message header character

◆ seeState()

const SeeState & rcsc::PlayerAgent::seeState ( ) const

get see state

Returns
const reference to the see state instance

◆ seeTimeStamp()

const TimeStamp & rcsc::PlayerAgent::seeTimeStamp ( ) const

get time stamp of see message when see message is received

Returns
const reference to the time stamp object

◆ setArmAction()

void rcsc::PlayerAgent::setArmAction ( ArmAction act)

reserve pointto action

Parameters
actpointer to the action. must be a dynamically allocated object.

◆ setFocusAction()

void rcsc::PlayerAgent::setFocusAction ( FocusAction act)

reserve change_focus action

Parameters
actpointer to the action. must be a dynamically allocated object.

◆ setIntention()

void rcsc::PlayerAgent::setIntention ( SoccerIntention intention)

set intention object

Parameters
intentionpointer to the dynamically allocated object.

◆ setNeckAction()

void rcsc::PlayerAgent::setNeckAction ( NeckAction act)

reserve turn neck action

Parameters
actpointer to the action. must be a dynamically allocated object.

◆ setViewAction()

void rcsc::PlayerAgent::setViewAction ( ViewAction act)

reserve change view action

Parameters
actpointer to the action. must be a dynamically allocated object.

◆ visualSensor()

const VisualSensor & rcsc::PlayerAgent::visualSensor ( ) const

get visual sensor

Returns
const reference to the visual sensor instance

◆ world()

const WorldModel & rcsc::PlayerAgent::world ( ) const
inline

get worldmodel

Returns
const reference to world model instance

The documentation for this class was generated from the following file: