Class DomainExpert
Defined in File DomainExpert.hpp
Inheritance Relationships
Base Type
public plansys2::DomainExpertInterface(Class DomainExpertInterface)
Class Documentation
-
class DomainExpert : public plansys2::DomainExpertInterface
Class responsible for managing the internal structure of a PDDL domain.
The DomainExpert class allows loading, extending, and querying PDDL domains. It provides methods to retrieve information about types, constants, predicates, functions, actions, and durative actions, as well as to obtain the full domain or check the existence of a specific domain.
Public Functions
-
explicit DomainExpert(const std::string &domain)
Constructor that initializes the DomainExpert with the content of a PDDL domain.
- Parameters:
domain – [in] The content of a PDDL domain.
-
void extendDomain(const std::string &domain)
Extends the current DomainExpert with another PDDL domain.
- Parameters:
domain – [in] The content of a PDDL domain to extend the current one.
-
virtual std::string getName()
Get the name of the domain.
- Returns:
std::string The name of the domain.
-
virtual std::vector<std::string> getTypes()
Get the types defined in the domain.
- Returns:
std::vector<std::string> The names of the types defined in the domain.
-
virtual std::vector<std::string> getConstants(const std::string &type)
Get the constants defined for a given type.
- Parameters:
type – [in] The name of the type.
- Returns:
std::vector<std::string> List of constant names for the specified type.
-
virtual std::vector<plansys2::Predicate> getPredicates()
Get the predicates defined in the domain.
- Returns:
std::vector<plansys2::Predicate> Vector containing the predicates defined in the domain.
-
virtual std::optional<plansys2::Predicate> getPredicate(const std::string &predicate)
Get the details of a predicate defined in the domain.
- Parameters:
predicate – [in] The name of the predicate.
- Returns:
std::optional<plansys2::Predicate> Predicate object containing the predicate name and its parameters (name and type). If the predicate does not exist, the returned value is empty.
-
virtual std::vector<plansys2::Function> getFunctions()
Get the functions defined in the domain.
- Returns:
std::vector<plansys2::Function> Vector containing the functions defined in the domain.
-
virtual std::optional<plansys2::Function> getFunction(const std::string &function)
Get the details of a function defined in the domain.
- Parameters:
function – [in] The name of the function.
- Returns:
std::optional<plansys2::Function> The function name and its parameters (name and type). If the function does not exist, the returned value is empty.
-
plansys2_msgs::msg::Derived getDerivedFromDomain(const unsigned int &derived_index, const std::vector<std::string> ¶ms = {})
Get a derived predicate from the domain given an index and parameters.
- Parameters:
derived_index – The index of the derived predicate in the domain.
params – The parameters for the derived predicate (empty by default).
- Returns:
plansys2_msgs::msg::Derived The derived predicate message.
-
virtual std::vector<plansys2_msgs::msg::Derived> getDerivedPredicates()
Get the derived predicates existing in the domain.
Get the derived predicates defined in the domain.
- Returns:
std::vector<plansys2::Predicate> Vector containing the derived predicates defined in the domain.
-
plansys2::DerivedResolutionGraph getDerivedResolutionGraph()
-
virtual std::vector<plansys2_msgs::msg::Derived> getDerivedPredicate(const std::string &predicate, const std::vector<std::string> ¶ms = {})
Get the details of a derived predicate defined in the domain.
- Parameters:
predicate – [in] The name of the derived predicate.
params – [in] Optional parameters for the predicate.
- Returns:
std::vector<plansys2_msgs::msg::Derived> Vector containing the details of the derived predicate, including its name, parameters (name and type) and preconditions. If the derived predicate does not exist, the returned value is empty.
-
virtual std::vector<std::string> getActions()
Get the regular actions defined in the domain.
- Returns:
std::vector<std::string> Vector containing the names of the actions.
-
virtual plansys2_msgs::msg::Action::SharedPtr getAction(const std::string &action, const std::vector<std::string> ¶ms = {})
Get the details of a regular action defined in the domain.
- Parameters:
action – [in] The name of the action.
params – [in] Optional parameters for the action.
- Returns:
plansys2_msgs::msg::Action object containing the action name, parameters, requirements, and effects. If the action does not exist, the returned value is nullptr.
-
virtual std::vector<std::string> getDurativeActions()
Get the durative actions defined in the domain.
- Returns:
std::vector<std::string> Vector containing the names of the durative actions.
-
virtual plansys2_msgs::msg::DurativeAction::SharedPtr getDurativeAction(const std::string &action, const std::vector<std::string> ¶ms = {})
Get the details of a durative action defined in the domain.
- Parameters:
action – [in] The name of the durative action.
params – [in] Optional parameters for the action.
- Returns:
plansys2_msgs::msg::DurativeAction object containing the action name, parameters, requirements, and effects. If the action does not exist, the returned value is nullptr.
-
virtual std::string getDomain()
Get the current domain definition as a string,.
which can be used to save to a file or initialize another domain.
- Returns:
std::string The current domain definition in PDDL format.
-
bool existDomain(const std::string &domain_name)
Checks if a domain with the given name exists.
- Parameters:
domain_name – [in] The name of the domain.
- Returns:
true if the domain exists, false otherwise.
-
explicit DomainExpert(const std::string &domain)