Class POPFPlanSolver

Inheritance Relationships

Base Type

  • public plansys2::PlanSolverBase

Class Documentation

class POPFPlanSolver : public plansys2::PlanSolverBase

Plan solver implementation that uses the POPF planning system.

This class implements the PlanSolverBase interface using the POPF (Partial Order Planning Forward) planner. It handles writing domain and problem files to disk, executing the planner, and parsing the resulting plan.

Public Functions

POPFPlanSolver()

Default constructor.

std::optional<std::filesystem::path> create_folders(const std::string &node_namespace)

Creates folder structure for storing temporary planning files.

Parameters:

node_namespace[in] Namespace to use for folder structure.

Returns:

std::optional<std::filesystem::path> Created folder path if successful, std::nullopt on failure.

virtual void configure(rclcpp_lifecycle::LifecycleNode::SharedPtr lc_node, const std::string &plugin_name) override

Configures the plan solver with runtime parameters.

Sets up necessary parameters including command-line arguments for the planner and the output directory for temporary files.

Parameters:
  • lc_node[in] Pointer to the lifecycle node.

  • plugin_name[in] Name of the plugin to use for parameter namespacing.

virtual std::optional<plansys2_msgs::msg::Plan> getPlan(const std::string &domain, const std::string &problem, const std::string &node_namespace = "", const rclcpp::Duration solver_timeout = 15s)

Calls the planner to generate a plan for the given domain and problem.

This method writes the domain and problem to temporary files, executes the POPF planner, and parses the resulting plan.

Parameters:
  • domain[in] PDDL domain description.

  • problem[in] PDDL problem description.

  • node_namespace[in] Namespace to use for temporary files.

  • solver_timeout[in] Maximum time allowed for planning (default: 15 seconds).

Returns:

The generated plan if successful, nullopt otherwise.

virtual bool isDomainValid(const std::string &domain, const std::string &node_namespace = "")

Checks if a domain is valid by attempting to solve a simple problem.

Parameters:
  • domain[in] PDDL domain description to validate.

  • node_namespace[in] Namespace to use for temporary files.

Returns:

True if the domain is valid, false otherwise.

Protected Functions

std::optional<plansys2_msgs::msg::Plan> parse_plan_result(const std::string &plan_path)

Parses the plan output file into a Plan message.

Reads the plan file generated by POPF and converts it into the ROS message format. The plan file format is expected to have lines like: “0.0000: (action param1 param2) [duration]”

Parameters:

plan_path[in] Path to the plan file.

Returns:

std::optional<plansys2_msgs::msg::Plan> The parsed plan if successful, nullopt otherwise.