Overview of PlanSys2 Core
rollingpopf, downward) must implement the interfaces defined in this package.repository·rolling·Indexed 19 days ago
https://github.com/plansys2/ros2_planning_systemA PDDL-based planning framework for ROS2 that enables robotics developers to implement intelligent behaviors through automated planning. The system includes a Domain Expert for PDDL domain maintenance, an Executor module for plan lifecycle management and requirement checking, and support for implementing actions via the bt_action_node and BehaviorTree.CPP. It provides a set of core interfaces for custom planners and a specialized messaging system for representing PDDL expressions as trees.
popf, downward) must implement the interfaces defined in this package.The Planner module is responsible for generating plans by invoking a PDDL solver. By default, it uses the popf binary. The module works by calling the solver binary and parsing its output.
The core component is the plansys2::PlannerNode class. While it inherits from rclcpp_lifecycle::LifecycleNode, its functionality is currently implemented in the active phase.
plansys2_popf_plan_solver package provides a ROS 2 interface for the POPF planner. It allows the Planning System to solve PDDL (Planning Domain Definition Language) problems using the POPF engine.The Problem Expert module is responsible for maintaining the PDDL problem's instances, predicates, and goals. It acts as a dynamic and volatile repository of the current problem state.
Key components include:
plansys2::ProblemExpertNode: A rclcpp_lifecycle::LifecycleNode that provides the ROS2 interface. Currently, its functionality is available in the active phase.plansys2::ProblemExpert: The core logic class that maintains the problem instance; it is independent of ROS2.plansys2::ProblemExpertClient: A client class designed to hide the complexity of ROS2 services and messages. It implements the plansys2::ProblemExpertInterface, making its API similar to the core ProblemExpert class.To ensure consistency, the Problem Expert instantiates a plansys2::DomainExpertClient and verifies every update query against the domain to check for validity.
Instead of polling the Problem Expert for changes, you can subscribe to the /problem_expert/update_notify topic. The module publishes a std_msgs::msg::Empty message to this topic whenever any update occurs in the Problem. This allows other modules and applications to react immediately to state changes.
# Example of monitoring updates via CLI
ros2 topic echo /problem_expert/update_notifyA PDDL problem file defines the specific instance for a domain. It requires:
:init): A list of predicates and facts that are true at the start of the plan (e.g., connectivity between locations, robot positions, battery status).:goal): A logical expression defining the state that must be achieved to complete the plan.( define ( problem problem_1 )
( :domain plansys2 )
( :objects
leia - robot
room_1 room_2 - room
corridor_1 - corridor
zone_1_1 zone_1_2 zone_recharge - zone
)
( :init
( connected room_1 corridor_1 )
...
( battery_low leia )
( robot_at leia zone_1_1 )
)
( :goal
( and
( robot_at leia zone_1_2 )
)
)
)The Executor module manages the lifecycle of plan execution. It requests a plan from the Planner and executes it by calling action nodes in the client application.
Key responsibilities include:
The execution flow involves the ExecutorNode requesting the domain and problem, obtaining a plan from the Planner, and then creating a plansys2::ActionExecutor for each individual action in that plan.
The Domain Expert module is responsible for maintaining the PDDL (Planning Domain Definition Language) domain. It consists of two main parts:
plansys2::DomainExpertNode: A rclcpp_lifecycle::LifecycleNode that acts as the ROS2 interface. During its configuration phase, it reads a model_file parameter, which specifies the path to the .pddl file used to define the model.plansys2::DomainExpert: The core logic class that maintains the domain. This class is independent of ROS2.While the Domain Expert is active, its internal state does not change; instead, users interact with it via ROS2 services to query information about the domain.
The primary entry point for plan execution is the plansys2::ExecutorNode class (implemented in executor_node.cpp).
Plan execution is handled via the ROS2 action /execute_plan using the plansys2_msgs::action::ExecutePlan action type. Note that the goal must already be present in the Domain Expert before requesting plan execution.
When executing a plan, the ExecutorNode creates a plansys2::ActionExecutor for each action. This object manages the lifetime of a single action and invokes the client application's implementation using the plansys2_msgs::action::ExecuteAction ROS2 action.
// The main class for plan execution
plansys2::ExecutorNodePlansys2 is a modular planning and execution framework composed of four primary modules. To build or extend the system, you must understand the responsibilities of each:
PlanSys2 supports PDDL (Planning Domain Definition Language) domains that utilize typing, sub-typing, and durative actions.
room, zone, and corridor can all be sub-types of a general place type. This allows actions to be parameterized by the general type while specific objects are assigned to sub-types.at start: Conditions that must be true when the action begins, or effects that happen immediately.over all: Conditions that must remain true throughout the entire duration of the action.at end: Effects that occur once the action completes.:strips, :typing, :adl, :fluents, and :durative-actions.;; Example of Types and Sub-Types
(:types
robot
room zone corridor - place
)
;; Example of a Durative Action
(:durative-action move
:parameters (?r - robot ?p1 ?p2 - place)
:duration ( = ?duration 5)
:condition (and
(at start(connected ?p1 ?p2))
(at start(robot_at ?r ?p1))
(over all(battery_full ?r))
)
:effect (and
(at start(not(robot_at ?r ?p1)))
(at end(robot_at ?r ?p2))
)
)