This repository contains the implementation for the Automated Planning Theory and Practice course assignment (AY 2024-2025) at University of Trento.
The objective of the assignment is to model and solve planning problems in a healthcare scenario using PDDL
(Planning Domain Definition Language) and HDDL
(Hierarchical Domain Definition Language), as well as to integrate a temporal planning model within a robotic framework leveraging the PlanSys2
infrastructure in ROS2.
The assignment focuses on developing and testing planning models with increasing complexity:
- Problem 1: Modeling a base
PDDL
domain for task execution. - Problem 2: Extending the base
PDDL
domain with more complex tasks. - Problem 3: Structuring tasks using Hierarchical Task Networks (HTN).
- Problem 4: Introducing temporal planning with durative actions and concurrency constraints.
- Problem 5: Executing the temporal model in
PlanSys2
.
More details, explanations and output examples are present in the report.pdf file.
Each folder in the repo contains the PDDL
/HDDL
domain and problem files, along with the corresponding PlanSys2
implementation for the last task.
# Clone the repository
git https://github.com/lorenzialessandro/health-care-planning
cd health-care-planning
# Run a simple example (Problem 1) - See instructions below
cd problem_1
fast-downward.py domain.pddl p2_simple.pddl --search "astar(lmcut())"
health-care-planning/
├── problem_1/ # Base PDDL implementation
│ ├── domain.pddl
│ ├── p*.pddl # Problem instances
│ └── p*.plan # Output plans instances
├── problem_2/ # Extended PDDL domain
├── problem_3/ # HTN implementation
├── problem_4/ # Temporal planning
└── problem_5/ # PlanSys2 integration
└── plansys2_problem_5/
To run this project, ensure you have the following installed:
- ROS2 Humble: Required for
PlanSys2
- Python 3.8+ (for scripting and running planners)
- Java (JDK 11+) (for PANDA planner in Problem 3)
- Planning tools:
sudo apt update && sudo apt install -y ros-humble-plansys2
rosdep install --from-paths ./ --ignore-src -r -y
colcon build --symlink-install
source install/setup.bash
The first domain established a solid foundation by coordinating robots for single-box deliveries and patient transport.
To evaluate the domain.pddl, different problems of increasing complexity can be tested:
- p1.pddl: The most complex scenario, it features a diversified roadmap, multiple supplies, and several patients.
- p2_simple.pddl: A simpler scenario with two supply locations and two patients, where items are positioned in different locations. Only one robot of each type is available.
- p3_simple_multiple.pddl: Similar to p2_simple.pddl but with a total of four robots.
The folder contains the output plans of all the problems, p1.pddl
was solved using LAMA-first
, while the simplest two were solved using Fast Downward
.
Navigate to the problem directory:
cd problem_1
Problems can be executed using LAMA-first
, Fast Downward
or LAMA
:
downward --alias lama-first domain.pddl p1.pddl
fast-downward.py domain.pddl p1.pddl --search "astar(lmcut())"
downward --alias lama domain.pddl p1.pddl
In the second and next domains, the carriers are introduced and new actions are implemented for the handling of multiple box operations.
Similar to the previous problem, various settings and goals are tested to evaluate the domain.pddl conformity, this time incorporating the new carrier
type with distinct capacities to assess the robot’s ability to handle multiple boxes simultaneously.
- p1.pddl: same as the previous one, but introduces two types of box-robots (and carriers), one with a maximum capacity of 3 boxes and the other with a maximum capacity of 2 boxes.
- p2_simple.pddl: variant of the one in the previous domain, modified to include the carrier with a 3-box capacity.
Navigate to the problem directory:
cd problem_2
Problems can be executed using LAMA-first
, Fast Downward
or LAMA
, following previous instructions.
The third scenario is modeled using Hierarchical Task Networks (HTN). All actions and predicates remain the same as in Problem 2, but new abstract tasks have been introduced, along with their corresponding methods.
The tested problem p1.hddl is inspired by the main problem from the previous scenarios and involves delivering three supplies and accompanying two patients.
Navigate to the problem directory:
cd problem_3
Problems can be executed using PANDA
framework (Planning and Acting in a Network Decomposition Architecture):
java -jar PANDA.jar -parser hddl domain.hddl p1.hddl
This problem introduces the durative actions extension, where time and temporal constraints must be considered. The goal is to add a duration for each action from Problem 2 and integrate time constraints to prevent certain operations from being executed in parallel.
The new domain.pddl can be tested with:
- p1.pddl: complex scenario with the goal of delivering four supplies and accompanying three patients, utilizing two box-carrying robots and one patient transport robot
- p2_simple.pddl as in Problem 2, featuring two delivery tasks and two patient transport tasks.
Navigate to the problem directory:
cd problem_4
Problems can be executed using OPTIC
or POPF
:
optic domain.pddl p1.pddl
popf domain.pddl p1.pddl
The final problem involves the execution of the Problem 4 scenario in PlanSys2
.
The domain.pddl used is the same in Problem 4.
The injected knowledge mimics the p1.pddl
scenario from the previous problem and is represented in file commands
(here).
Once the plan is run, the ROS2
terminal visualizes the corresponding execution, showing that all tasks are performed as expected.
This problem requires two terminals for execution.
# Navigate to the problem directory
cd problem_5/plansys2_problem_5/
# Source ROS2
source /opt/ros/humble/setup.bash
# Install dependencies
rosdep install --from-paths ./ --ignore-src -r -y
# Build the workspace
colcon build --symlink-install
# Source the built workspace
source install/setup.bash
# Launch the planning system
ros2 launch plansys2_problem_5 plansys2_problem_5_launch.py
Alternatively, you can directly launch the terminal1.sh inside the problem directory, that run these instructions via:
./terminal1.sh
# Navigate to the problem directory
cd problem_5/plansys2_problem_5/
# Source ROS2
source /opt/ros/humble/setup.bash
# Source the built workspace
source install/setup.bash
# Launch the planner terminal
ros2 run plansys2_terminal plansys2_terminal
# Source the commands
source /mnt/d/health-care-planning/problem_5/plansys2_problem_5/launch/commands
# Generate the plan
get plan
# Execute the plan
run
The last instruction produces the visualization of the plan execution in Terminal 1.
-
Planner not found
- Ensure the planner is installed and accessible from the terminal.
- Example:
export PATH=$PATH:/path/to/fast-downward
-
ROS2 package errors
- Ensure ROS2 environment is sourced before running commands:
source /opt/ros/humble/setup.bash
- Ensure ROS2 environment is sourced before running commands:
-
Plan execution fails in PlanSys2
- Check if the knowledge base is correctly injected (
commands
file in Problem 5).
- Check if the knowledge base is correctly injected (
- Plan Generation Timeout: Increase search time limit
- Memory Errors: Reduce problem complexity or increase swap space
- PlanSys2 Connection Issues: Check ROS2 network configuration
Alessandro Lorenzi - alessandro.lorenzi-1@studenti.unitn.it