Fawkes API
Fawkes Development Version
|
#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 > ¶ms, std::multimap< std::string, std::string > &messages) const |
Perform mapping. More... | |
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:
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:
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:
== 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.
Definition at line 30 of file map_skill.h.
fawkes::ActionSkillMapping::ActionSkillMapping | ( | ) |
Constructor.
Definition at line 101 of file map_skill.cpp.
fawkes::ActionSkillMapping::ActionSkillMapping | ( | std::map< std::string, std::string > & | mappings | ) |
Constructor with initial mapping.
mappings | initial mapping |
Definition at line 108 of file map_skill.cpp.
void fawkes::ActionSkillMapping::add_mapping | ( | const std::string & | action_name, |
const std::string & | skill_string_template | ||
) |
Add another mapping.
action_name | name of action to map |
skill_string_template | substitutation template |
Definition at line 118 of file map_skill.cpp.
bool fawkes::ActionSkillMapping::has_mapping | ( | const std::string & | action_name | ) | const |
Check if mapping for an action exists.
action_name | name of action to check |
Definition at line 129 of file map_skill.cpp.
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.
name | name of action |
params | parameters as key value pairs |
messages | contains informational and error messages upon return. The key denotes the severity, e.g., WARN or ERROR, the value is the actual message. |
Definition at line 143 of file map_skill.cpp.