Fawkes API
Fawkes Development Version
|
An ActionExecutor that executes an activity using the Skiller. More...
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... | |
![]() | |
ActionExecutor (Logger *logger) | |
Constructor of an abstract executor. More... | |
![]() | |
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... | |
![]() | |
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... | |
Interface * | bbil_data_interface (const char *iuid) throw () |
Get interface instance for given UID. More... | |
Interface * | bbil_message_interface (const char *iuid) throw () |
Get interface instance for given UID. More... | |
Interface * | bbil_reader_interface (const char *iuid) throw () |
Get interface instance for given UID. More... | |
Interface * | bbil_writer_interface (const char *iuid) throw () |
Get interface instance for given UID. More... | |
Protected Attributes | |
BlackBoard * | blackboard_ |
The blackboard to use to access the skiller. More... | |
bool | blackboard_owner_ |
True if this executor is owning its blackboard. More... | |
![]() | |
std::shared_ptr< gologpp::Activity > | running_activity_ |
A pointer to the currently running activity. More... | |
Logger * | logger_ |
The logger to use for logging messages. More... | |
Additional Inherited Members | |
![]() | |
enum | QueueEntryType { DATA = 0, MESSAGES = 1, READER = 2, WRITER = 3 } |
Queue entry type. More... | |
typedef std::list< QueueEntry > | InterfaceQueue |
Queue of additions/removal of interfaces. More... | |
typedef std::map< std::string, Interface * > | InterfaceMap |
Map of currently active event subscriptions. More... | |
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.
Definition at line 44 of file skiller_action_executor.h.
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.
logger | A logger instance to use |
blackboard | The blackboard to use to connect to the SkillerInterface |
config | The config to read the skill mapping from |
cfg_prefix | The 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().
|
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().
|
overridevirtual |
Update the status of the activity according to the Skiller status.
iface | The 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.
|
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.
activity | An activity to execute |
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().
|
protected |
Get the name of the executor; mainly used for logging.
Definition at line 176 of file skiller_action_executor.cpp.
Referenced by SkillerActionExecutor(), and start().
|
overridevirtual |
Start the given activity.
Instruct the skiller to execute the activity.
activity | the 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().
|
overridevirtual |
Stop the activity if it is currently running.
If the given activity does not match the currently running activity, do nothing.
activity | The 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_.
|
protected |
The blackboard to use to access the skiller.
Definition at line 59 of file skiller_action_executor.h.
Referenced by SkillerActionExecutor(), and ~SkillerActionExecutor().
|
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().