Fawkes API  Fawkes Development Version
fawkes::ActionSkillMapping Class Reference

Class to maintain and perform mapping from actions to skills. More...

#include "map_skill.h"

Public Member Functions

 ActionSkillMapping ()
 Constructor. More...
 
 ActionSkillMapping (std::map< std::string, std::string > &mappings)
 Constructor with initial mapping. More...
 
void add_mapping (const std::string &action_name, const std::string &skill_string_template)
 Add another mapping. More...
 
bool has_mapping (const std::string &action_name) const
 Check if mapping for an action exists. More...
 
std::string map_skill (const std::string &name, const std::map< std::string, std::string > &params, std::multimap< std::string, std::string > &messages) const
 Perform mapping. More...
 

Detailed Description

Class to maintain and perform mapping from actions to skills.

Given an action name and parameters, transform to skill string according to some predetermined mapping.

A mapping is a tuple of two elements:

  • parameter key or path element (left of the colon)
  • parameter value These elements are described in the following.

The configuration key or path element is the PDDL operator name.

The mapping value can use the following elements as a pattern modification for the skill string. Note: parameters are always converted to lower-case by ROSPlan (at least in the default combination with POPF).

Variable substitution has the general pattern ?(varname)M, where varname is the name of the operator parameter and M a modifier. The modifier must be one of:

  • s or S: convert value to string, that is add qutotation marks around the value. s passes the string as is, S converts to uppercase.
  • y or Y: pass value as symbol, i.e., the string value as is without quotation marks. Y additionally converts to upper case.
  • i: converts the value to an integer
  • f: converts the value to a float value

Additionally, the arguments may be modified with a chain of regular expressions. Then, the expression looks like this: ?(var|/pattern/replace/|...) There can be an arbitrary number of regular expressions chained by the pipe (|) symbol. The "/pattern/replace/" can be a regular expression according to the C++ ECMAScript syntax. NOTE: the expressions may contain neither a slash (/) nor a pipe (|), not even if quoted with a backslash. This is because a rather simple pattern is used to extract the regex from the argument string. The replacement string may contain reference to matched groups (cf. http://ecma-international.org/ecma-262/5.1/ *sec-15.5.4.11). In particular, the following might be useful:

  • $$: an actual dollar sign
  • $&: the full matched substring
  • $n: the n'th capture (may also be $nn for 10 <= nn <= 99) Note that regular expression matching is performed case-insensitive, that is because PDDL itself is also case-insensitive.

== Examples == Examples contain three elements, the typed PDDL operator name with parameters, the conversion string, and one or more conversion examples of grounded actions to actuall skill strings.

PDDL: (move ?r - robot ?from ?to - location) Param: move: ppgoto{place=?(to)S} Examples: (move R-1 START C-BS-I) -> ppgoto{place="C-BS-I"}

PDDL: (enter-field ?r - robot ?team-color - team-color) Param: enter-field: drive_into_field{team=?(team-color)S, wait=?(r|/R-1/0.0/|/R-2/3.0/|/R-3/6.0/)f} Examples: (enter_field R-1 CYAN) -> drive_into_field{team="CYAN", wait=0.000000} (enter_field R-2 CYAN) -> drive_into_field{team="CYAN", wait=3.000000} Note: the chaining of regular expressions to fill in a parameter based on the specific value of another parameter. You can also see that arguments can be referenced more than once.

Author
Tim Niemueller

Definition at line 27 of file map_skill.h.

Constructor & Destructor Documentation

◆ ActionSkillMapping() [1/2]

fawkes::ActionSkillMapping::ActionSkillMapping ( )

Constructor.

Definition at line 97 of file map_skill.cpp.

◆ ActionSkillMapping() [2/2]

fawkes::ActionSkillMapping::ActionSkillMapping ( std::map< std::string, std::string > &  mappings)

Constructor with initial mapping.

Parameters
mappingsinitial mapping

Definition at line 104 of file map_skill.cpp.

Member Function Documentation

◆ add_mapping()

void fawkes::ActionSkillMapping::add_mapping ( const std::string &  action_name,
const std::string &  skill_string_template 
)

Add another mapping.

Parameters
action_namename of action to map
skill_string_templatesubstitutation template

Definition at line 114 of file map_skill.cpp.

◆ has_mapping()

bool fawkes::ActionSkillMapping::has_mapping ( const std::string &  action_name) const

Check if mapping for an action exists.

Parameters
action_namename of action to check
Returns
true if mapping exists, false otherwise

Definition at line 125 of file map_skill.cpp.

Referenced by fawkes::gpp::SkillerActionExecutor::can_execute_activity().

◆ map_skill()

std::string fawkes::ActionSkillMapping::map_skill ( const std::string &  name,
const std::map< std::string, std::string > &  params,
std::multimap< std::string, std::string > &  messages 
) const

Perform mapping.

Parameters
namename of action
paramsparameters as key value pairs
messagescontains informational and error messages upon return. The key denotes the severity, e.g., WARN or ERROR, the value is the actual message.
Returns
The skill string of the mapped action, or an empty string in case of an error.

Definition at line 139 of file map_skill.cpp.


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