Fawkes API  Fawkes Development Version
fawkes::ExecutionTimeEstimator Class Referenceabstract

An abstract estimator for the execution time of a skill. More...

Inheritance diagram for fawkes::ExecutionTimeEstimator:

Classes

class  Property
 A configurable property that is skill-specific and may have a default value. More...
 
class  Skill
 A structured representation of a skill. More...
 

Public Member Functions

 ExecutionTimeEstimator (Configuration *config, const ::std::string &cfg_prefix)
 Constructor. More...
 
virtual ~ExecutionTimeEstimator ()=default
 Destructor. More...
 
virtual float get_execution_time (const Skill &skill)=0
 Get the estimated execution time for the given skill string. More...
 
virtual bool can_execute (const Skill &skill)
 Check if this estimator is both allowed and able to give an estimate for a given skill. More...
 
virtual std::pair< SkillerInterface::SkillStatusEnum, std::string > execute (const Skill &skill)
 Let the estimator know that we are executing this skill, so it can apply possible side effects. More...
 

Protected Member Functions

std::map< std::string, Skillget_skills_from_config (const std::string &path) const
 Load skill descriptions from a yaml config. More...
 
virtual bool can_provide_exec_time (const Skill &skill) const =0
 Check if this estimator can give an estimate for a given skill. More...
 
template<typename T >
get_property (const Property< T > &property) const
 Get the current property value for active_whitelist_entry_. More...
 

Protected Attributes

Configuration *const config_
 Config to obtain common configurables. More...
 
const std::string cfg_prefix_
 Config prefix of the estimator. More...
 
const float speed_
 Config estimator-specific speedup factor. More...
 
std::map< std::string, Skill >::const_iterator active_whitelist_entry_
 Points to the whitelist entry that matches the skill to execute. More...
 
const std::map< std::string, Skillwhitelist_
 Whitelist of skills that the estimator is allowed to process. More...
 
const std::map< std::string, Skillblacklist_
 Blacklist of skills that the estimator must not process. More...
 

Detailed Description

An abstract estimator for the execution time of a skill.

Inherit from this class if you want to implement an estimator for a skill or a set of skills.

Definition at line 33 of file execution_time_estimator.h.

Constructor & Destructor Documentation

◆ ExecutionTimeEstimator()

fawkes::ExecutionTimeEstimator::ExecutionTimeEstimator ( Configuration config,
const ::std::string &  cfg_prefix 
)

Constructor.

Load config values that are common for all executors.

Parameters
configconfiguration to read all values from
cfg_prefixprefix where the estimator-specific configs are located

Definition at line 109 of file execution_time_estimator.cpp.

References speed_.

◆ ~ExecutionTimeEstimator()

virtual fawkes::ExecutionTimeEstimator::~ExecutionTimeEstimator ( )
virtualdefault

Destructor.

Member Function Documentation

◆ can_execute()

bool fawkes::ExecutionTimeEstimator::can_execute ( const Skill skill)
virtual

Check if this estimator is both allowed and able to give an estimate for a given skill.

Parameters
skillThe skill object to check.
Returns
true if this estimator can give an execution time estimate for the given skill.

Reimplemented in fawkes::ConfigExecutionTimeEstimator.

Definition at line 121 of file execution_time_estimator.cpp.

References active_whitelist_entry_, blacklist_, can_provide_exec_time(), and whitelist_.

Referenced by fawkes::ConfigExecutionTimeEstimator::can_execute().

◆ can_provide_exec_time()

bool fawkes::ExecutionTimeEstimator::can_provide_exec_time ( const Skill skill) const
protectedpure virtual

Check if this estimator can give an estimate for a given skill.

Parameters
skillThe skill object to check.
Returns
true if this estimator can give an execution time estimate for the given skill.

Implemented in fawkes::ConfigExecutionTimeEstimator, fawkes::NavGraphEstimator, and fawkes::LookupEstimator.

Referenced by can_execute().

◆ execute()

std::pair< SkillerInterface::SkillStatusEnum, std::string > fawkes::ExecutionTimeEstimator::execute ( const Skill skill)
inlinevirtual

Let the estimator know that we are executing this skill, so it can apply possible side effects.

Parameters
skillThe skill to execute
Returns
skill status after simulated execution along with an error description in case the skill fails

Reimplemented in fawkes::NavGraphEstimator, and fawkes::LookupEstimator.

Definition at line 79 of file execution_time_estimator.h.

◆ get_execution_time()

float fawkes::ExecutionTimeEstimator::get_execution_time ( const Skill skill)
pure virtual

Get the estimated execution time for the given skill string.

Parameters
skillThe skill object to compute the execution time for.
Returns
The execution time in seconds.

Implemented in fawkes::ConfigExecutionTimeEstimator, fawkes::NavGraphEstimator, and fawkes::LookupEstimator.

◆ get_property()

template<typename T >
template float fawkes::ExecutionTimeEstimator::get_property ( const Property< T > &  property) const
protected

Get the current property value for active_whitelist_entry_.

Parameters
propertyproperty where the current value should be retrieved from
Returns
property accoring to active_whitelist_entry_ or the default value if no whitelist entry is active

Definition at line 233 of file execution_time_estimator.cpp.

References active_whitelist_entry_, and whitelist_.

Referenced by fawkes::NavGraphEstimator::can_provide_exec_time(), fawkes::LookupEstimator::get_execution_time(), fawkes::NavGraphEstimator::get_execution_time(), and fawkes::ConfigExecutionTimeEstimator::get_execution_time().

◆ get_skills_from_config()

std::map< std::string, Skill > fawkes::ExecutionTimeEstimator::get_skills_from_config ( const std::string &  path) const
protected

Load skill descriptions from a yaml config.

The skills are represented via suffixes /<description-id>/name and /<description-id>/args following the

Parameters
pathconfig path under which the skill descriptions are located
Returns
all skills found under the given path sorted by <description-id>.

Definition at line 205 of file execution_time_estimator.cpp.

References config_, fawkes::Configuration::search(), fawkes::str_join(), and fawkes::str_split().

Member Data Documentation

◆ active_whitelist_entry_

std::map<std::string, Skill>::const_iterator fawkes::ExecutionTimeEstimator::active_whitelist_entry_
protected

Points to the whitelist entry that matches the skill to execute.

Definition at line 98 of file execution_time_estimator.h.

Referenced by can_execute(), fawkes::ConfigExecutionTimeEstimator::can_provide_exec_time(), and get_property().

◆ blacklist_

const std::map<std::string, Skill> fawkes::ExecutionTimeEstimator::blacklist_
protected

Blacklist of skills that the estimator must not process.

Definition at line 102 of file execution_time_estimator.h.

Referenced by can_execute().

◆ cfg_prefix_

const std::string fawkes::ExecutionTimeEstimator::cfg_prefix_
protected

Config prefix of the estimator.

Definition at line 94 of file execution_time_estimator.h.

Referenced by fawkes::ConfigExecutionTimeEstimator::can_provide_exec_time().

◆ config_

Configuration* const fawkes::ExecutionTimeEstimator::config_
protected

Config to obtain common configurables.

Definition at line 92 of file execution_time_estimator.h.

Referenced by fawkes::ConfigExecutionTimeEstimator::can_provide_exec_time(), and get_skills_from_config().

◆ speed_

const float fawkes::ExecutionTimeEstimator::speed_
protected

◆ whitelist_

const std::map<std::string, Skill> fawkes::ExecutionTimeEstimator::whitelist_
protected

Whitelist of skills that the estimator is allowed to process.

Definition at line 100 of file execution_time_estimator.h.

Referenced by can_execute(), fawkes::ConfigExecutionTimeEstimator::can_provide_exec_time(), and get_property().


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