Class ProblemExpertClient

Inheritance Relationships

Base Type

Class Documentation

class ProblemExpertClient : public plansys2::ProblemExpertInterface

Client implementation for accessing the ProblemExpert node services.

This class provides a client interface to interact with the ProblemExpert node, implementing the ProblemExpertInterface. It allows managing PDDL problem elements such as instances, predicates, functions, and goals through ROS 2 services.

Public Functions

ProblemExpertClient()

Constructor for the ProblemExpertClient.

Initializes a ROS node and creates all the service clients needed to communicate with the ProblemExpert node.

virtual std::vector<plansys2::Instance> getInstances()

Get all instances in the problem.

Returns:

std::vector<plansys2::Instance> Vector containing all instances in the problem.

virtual bool addInstance(const plansys2::Instance &instance)

Add a new instance to the problem.

Parameters:

instance[in] The instance to be added.

Returns:

true if the instance was successfully added, false otherwise.

virtual bool removeInstance(const plansys2::Instance &instance)

Remove an instance from the problem.

Parameters:

instance[in] The instance to be removed.

Returns:

true if the instance was successfully removed, false otherwise.

virtual std::optional<plansys2::Instance> getInstance(const std::string &name)

Get a specific instance by name.

Parameters:

name[in] The name of the instance to retrieve.

Returns:

std::optional<plansys2::Instance> The instance if found, empty otherwise.

virtual std::vector<plansys2::Predicate> getPredicates()

Get all predicates in the problem.

Returns:

std::vector<plansys2::Predicate> Vector containing all predicates in the problem.

virtual bool addPredicate(const plansys2::Predicate &predicate)

Add a new predicate to the problem.

Parameters:

predicate[in] The predicate to be added.

Returns:

true if the predicate was successfully added, false otherwise.

virtual bool removePredicate(const plansys2::Predicate &predicate)

Remove a predicate from the problem.

Parameters:

predicate[in] The predicate to be removed.

Returns:

true if the predicate was successfully removed, false otherwise.

virtual bool existPredicate(const plansys2::Predicate &predicate)

Check if a predicate exists in the problem.

Parameters:

predicate[in] The predicate to check.

Returns:

true if the predicate exists, false otherwise.

virtual std::optional<plansys2::Predicate> getPredicate(const std::string &predicate)

Get a specific predicate by its expression.

Parameters:

expr[in] The expression of the predicate to retrieve.

Returns:

std::optional<plansys2::Predicate> The predicate if found, empty otherwise.

virtual std::vector<plansys2::Function> getFunctions()

Get all functions in the problem.

Returns:

std::vector<plansys2::Function> Vector containing all functions in the problem.

virtual bool addFunction(const plansys2::Function &function)

Add a new function to the problem.

Parameters:

function[in] The function to be added.

Returns:

true if the function was successfully added, false otherwise.

virtual bool removeFunction(const plansys2::Function &function)

Remove a function from the problem.

Parameters:

function[in] The function to be removed.

Returns:

true if the function was successfully removed, false otherwise.

virtual bool existFunction(const plansys2::Function &function)

Check if a function exists in the problem.

Parameters:

function[in] The function to check.

Returns:

true if the function exists, false otherwise.

virtual bool updateFunction(const plansys2::Function &function)

Update the value of an existing function.

Parameters:

function[in] The function with the updated value.

Returns:

true if the function was successfully updated, false otherwise.

virtual std::optional<plansys2::Function> getFunction(const std::string &function)

Get a specific function by its expression.

Parameters:

expr[in] The expression of the function to retrieve .

Returns:

std::optional<plansys2::Function> The function if found, empty otherwise.

virtual plansys2::Goal getGoal()

Get the current goal of the problem.

Returns:

plansys2::Goal The current goal.

virtual bool setGoal(const plansys2::Goal &goal)

Set a new goal for the problem.

Parameters:

goal[in] The goal to be set.

Returns:

true if the goal was successfully set, false otherwise.

virtual bool isGoalSatisfied(const plansys2::Goal &goal)

Check if a goal is satisfied in the current state.

Parameters:

goal[in] The goal to check for satisfaction.

Returns:

true if the goal is satisfied, false otherwise.

virtual bool clearGoal()

Clear the current goal from the problem.

Returns:

true if the goal was successfully cleared, false otherwise.

virtual bool clearKnowledge()

Clear all knowledge (instances, predicates, functions, and goal) from the problem.

Returns:

true if the knowledge was successfully cleared, false otherwise.

virtual std::string getProblem()

Get the complete PDDL problem as a string.

Returns:

std::string The complete PDDL problem string.

std::string getProblem(bool use_cache)

Get the complete PDDL problem as a string, with optional caching.

Parameters:

use_cache[in] If true, returns cached problem if available.

Returns:

std::string The complete PDDL problem string.

std::tuple<std::string, rclcpp::Time> getProblemWithTimestamp(bool use_cache = false)

Get the complete PDDL problem as a string, with timestamp.

Parameters:

use_cache[in] If true, returns cached problem if available.

Returns:

std::tuple<std::string, rclcpp::Time> A tuple containing the PDDL problem string and its timestamp.

virtual bool addProblem(const std::string &problem_str)

Add a complete PDDL problem from a string.

Parameters:

problem_str[in] The PDDL problem string to parse and add.

Returns:

true if the problem was successfully added, false otherwise.

inline rclcpp::Time getUpdateTime() const

Get the timestamp of the last problem update.

Returns:

rclcpp::Time The timestamp when the problem was last updated.

Public Members

std::string cached_problem_
rclcpp::Time problem_ts_