Fawkes API  Fawkes Development Version
fawkes::gpp::SkillerActionExecutor Class Reference

An ActionExecutor that executes an activity using the Skiller. More...

Inheritance diagram for fawkes::gpp::SkillerActionExecutor:

Public Member Functions

 SkillerActionExecutor (Logger *logger, BlackBoard *blackboard, Configuration *config, const std::string &cfg_prefix)
 Constructor. More...
 
virtual ~SkillerActionExecutor () override
 Destructor. More...
 
void start (std::shared_ptr< gologpp::Activity > activity) override
 Start the given activity. More...
 
void stop (std::shared_ptr< gologpp::Grounding< gologpp::Action >> activity) override
 Stop the activity if it is currently running. More...
 
bool can_execute_activity (std::shared_ptr< gologpp::Activity > activity) const override
 Check if we can execute the given activity. More...
 
virtual void bb_interface_data_changed (Interface *) override throw ()
 Update the status of the activity according to the Skiller status. More...
 
- Public Member Functions inherited from fawkes::gpp::ActionExecutor
 ActionExecutor (Logger *logger)
 Constructor of an abstract executor. More...
 
- Public Member Functions inherited from fawkes::BlackBoardInterfaceListener
 BlackBoardInterfaceListener (const char *name_format,...)
 Constructor. More...
 
virtual ~BlackBoardInterfaceListener ()
 Destructor. More...
 
const char * bbil_name () const
 Get BBIL name. More...
 
virtual bool bb_interface_message_received (Interface *interface, Message *message) throw ()
 BlackBoard message received notification. More...
 
virtual void bb_interface_writer_added (Interface *interface, unsigned int instance_serial) throw ()
 A writing instance has been opened for a watched interface. More...
 
virtual void bb_interface_writer_removed (Interface *interface, unsigned int instance_serial) throw ()
 A writing instance has been closed for a watched interface. More...
 
virtual void bb_interface_reader_added (Interface *interface, unsigned int instance_serial) throw ()
 A reading instance has been opened for a watched interface. More...
 
virtual void bb_interface_reader_removed (Interface *interface, unsigned int instance_serial) throw ()
 A reading instance has been closed for a watched interface. More...
 

Protected Member Functions

const char * name () const
 Get the name of the executor; mainly used for logging. More...
 
- Protected Member Functions inherited from fawkes::BlackBoardInterfaceListener
void bbil_add_data_interface (Interface *interface)
 Add an interface to the data modification watch list. More...
 
void bbil_add_message_interface (Interface *interface)
 Add an interface to the message received watch list. More...
 
void bbil_add_reader_interface (Interface *interface)
 Add an interface to the reader addition/removal watch list. More...
 
void bbil_add_writer_interface (Interface *interface)
 Add an interface to the writer addition/removal watch list. More...
 
void bbil_remove_data_interface (Interface *interface)
 Remove an interface to the data modification watch list. More...
 
void bbil_remove_message_interface (Interface *interface)
 Remove an interface to the message received watch list. More...
 
void bbil_remove_reader_interface (Interface *interface)
 Remove an interface to the reader addition/removal watch list. More...
 
void bbil_remove_writer_interface (Interface *interface)
 Remove an interface to the writer addition/removal watch list. More...
 
Interfacebbil_data_interface (const char *iuid) throw ()
 Get interface instance for given UID. More...
 
Interfacebbil_message_interface (const char *iuid) throw ()
 Get interface instance for given UID. More...
 
Interfacebbil_reader_interface (const char *iuid) throw ()
 Get interface instance for given UID. More...
 
Interfacebbil_writer_interface (const char *iuid) throw ()
 Get interface instance for given UID. More...
 

Protected Attributes

BlackBoardblackboard_
 The blackboard to use to access the skiller. More...
 
bool blackboard_owner_
 True if this executor is owning its blackboard. More...
 
- Protected Attributes inherited from fawkes::gpp::ActionExecutor
std::shared_ptr< gologpp::Activity > running_activity_
 A pointer to the currently running activity. More...
 
Loggerlogger_
 The logger to use for logging messages. More...
 

Additional Inherited Members

- Public Types inherited from fawkes::BlackBoardInterfaceListener
enum  QueueEntryType { DATA = 0 , MESSAGES = 1 , READER = 2 , WRITER = 3 }
 Queue entry type. More...
 
typedef std::list< QueueEntryInterfaceQueue
 Queue of additions/removal of interfaces. More...
 
typedef std::map< std::string, Interface * > InterfaceMap
 Map of currently active event subscriptions. More...
 

Detailed Description

An ActionExecutor that executes an activity using the Skiller.

An action is translated to a skill using the skill mapping from the configuration. If the Skiller's status changes, the activity's status is updated accordingly.

Author
Till Hofmann
See also
ActionSkillMapping

Definition at line 44 of file skiller_action_executor.h.

Constructor & Destructor Documentation

◆ SkillerActionExecutor()

fawkes::gpp::SkillerActionExecutor::SkillerActionExecutor ( Logger logger,
BlackBoard blackboard,
Configuration config,
const std::string &  cfg_prefix 
)

Constructor.

Create and initialize the executor, so a subsequent call to start() directly starts executing a skill.

Parameters
loggerA logger instance to use
blackboardThe blackboard to use to connect to the SkillerInterface
configThe config to read the skill mapping from
cfg_prefixThe spec-specific config prefix to use

Definition at line 71 of file skiller_action_executor.cpp.

References fawkes::BlackBoardInterfaceListener::bbil_add_data_interface(), fawkes::BlackBoard::BBIL_FLAG_DATA, blackboard_, fawkes::BlackBoard::close(), fawkes::Interface::has_writer(), fawkes::Logger::log_error(), fawkes::gpp::ActionExecutor::logger_, fawkes::Interface::msgq_enqueue(), name(), fawkes::BlackBoard::open_for_reading(), fawkes::Interface::read(), fawkes::BlackBoard::register_listener(), fawkes::BlackBoard::unregister_listener(), and fawkes::Exception::what_no_backtrace().

◆ ~SkillerActionExecutor()

fawkes::gpp::SkillerActionExecutor::~SkillerActionExecutor ( )
overridevirtual

Destructor.

Close all interfaces and unregister from the blackboard.

Definition at line 116 of file skiller_action_executor.cpp.

References blackboard_, blackboard_owner_, fawkes::BlackBoard::close(), fawkes::Interface::msgq_enqueue(), and fawkes::BlackBoard::unregister_listener().

Member Function Documentation

◆ bb_interface_data_changed()

void fawkes::gpp::SkillerActionExecutor::bb_interface_data_changed ( Interface iface)
throw (
)
overridevirtual

Update the status of the activity according to the Skiller status.

Parameters
ifaceThe interface that has changed

Reimplemented from fawkes::BlackBoardInterfaceListener.

Definition at line 217 of file skiller_action_executor.cpp.

References fawkes::SkillerInterface::S_FAILED, fawkes::SkillerInterface::S_FINAL, and fawkes::SkillerInterface::S_RUNNING.

◆ can_execute_activity()

bool fawkes::gpp::SkillerActionExecutor::can_execute_activity ( std::shared_ptr< gologpp::Activity >  activity) const
overridevirtual

Check if we can execute the given activity.

Check the action skill mapping whether the given action occurs in the mapping. If not, we cannot execute the activity.

Parameters
activityAn activity to execute
Returns
true iff the given activity can be executed by this executor

Implements fawkes::gpp::ActionExecutor.

Definition at line 133 of file skiller_action_executor.cpp.

References fawkes::ActionSkillMapping::has_mapping().

Referenced by fawkes::gpp::RemoteSkillerActionExecutor::can_execute_activity(), and start().

◆ name()

const char * fawkes::gpp::SkillerActionExecutor::name ( ) const
protected

Get the name of the executor; mainly used for logging.

Returns
The human-readable name of the executor

Definition at line 176 of file skiller_action_executor.cpp.

Referenced by SkillerActionExecutor(), and start().

◆ start()

void fawkes::gpp::SkillerActionExecutor::start ( std::shared_ptr< gologpp::Activity >  activity)
overridevirtual

Start the given activity.

Instruct the skiller to execute the activity.

Parameters
activitythe activity to execute

Implements fawkes::gpp::ActionExecutor.

Definition at line 143 of file skiller_action_executor.cpp.

References can_execute_activity(), fawkes::Logger::log_error(), fawkes::gpp::ActionExecutor::logger_, fawkes::Interface::msgq_enqueue(), name(), fawkes::gpp::ActionExecutor::running_activity_, and fawkes::Exception::what().

◆ stop()

void fawkes::gpp::SkillerActionExecutor::stop ( std::shared_ptr< gologpp::Grounding< gologpp::Action >>  activity)
overridevirtual

Stop the activity if it is currently running.

If the given activity does not match the currently running activity, do nothing.

Parameters
activityThe activity to stop

Implements fawkes::gpp::ActionExecutor.

Definition at line 164 of file skiller_action_executor.cpp.

References fawkes::Interface::msgq_enqueue(), and fawkes::gpp::ActionExecutor::running_activity_.

Member Data Documentation

◆ blackboard_

fawkes::gpp::SkillerActionExecutor::blackboard_
protected

The blackboard to use to access the skiller.

Definition at line 59 of file skiller_action_executor.h.

Referenced by SkillerActionExecutor(), and ~SkillerActionExecutor().

◆ blackboard_owner_

fawkes::gpp::SkillerActionExecutor::blackboard_owner_
protected

True if this executor is owning its blackboard.

Definition at line 60 of file skiller_action_executor.h.

Referenced by fawkes::gpp::RemoteSkillerActionExecutor::RemoteSkillerActionExecutor(), and ~SkillerActionExecutor().


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