C++ SFML visualization of the PDDL PlanSys2 planner (05.10.2023)
PDDL (Planning Domain Definition Language) is a language that allows to generate different plans by automatic systems. It dates back to 1998 when professor Drew McDermott and his colleagues decided to create a common standard language which will be main tool of the International Planning Competition (IPC; now it's named as ICAPS). The result of the implementation of their intention cannot be overestimated! This development was called "PDDL".
PDDL assumes that developer create a planning domain in one .pddl file and task or problem for the planner in another. In the first file programmer should include his view of subject area the planner will work with. In the second — a problem which planner has to solve. That repository in particular involves an arsenal of popular PDDL version 2.1. This version includes such novations as: numeric fluents, plan-metrics and durative/continuous actions. Read more about this in your preferred resources or visit my website: http://matesspace.h1n.ru (I'm from Russia :).
This repository you're now in demontrates PDDL cooperation with C++ libraries and tools. This project uses SFML library (https://www.sfml-dev.org/) for visualization of PDDL plan execution. Operators (or actions) of plans are generated by PlanSys2 planner which has to be installed into ROS2 system on Linux Ubuntu 22.04, for example. Main function in game.cpp file calls planner via Linux bash interpreter (though <cstdlib> system command).
Though temp files (which are always have been removed after program closing) a problem generating by Planner::getPDDLProblem() method and source domain in PDDL/game_domain.pddl file are sent to planner input. The PlanSys2 planner send a reply to C++ program via temp file containing a new plan. This file is read by Planner::getPDDLPlan() method and separate elements of this plan are created (C-structure objects that form a singly linked list). Every such element is simple action (operator), described in domain file, that has to be executed by C++ SFML visualization.
Then Game class just draws into SFML window all these actions step by step: cleaner's movement and stones' removing.
We have a cleaner who has to "destroy" all cobblestones lying on the playing field. This game field consists of separate cells with their texture and position. They are arranged in the form of a two-dimensional table and have a row number and a column number, which define their nominal coordinates. Size of the table is random and is generated via discrete uniform distribution of random variables whose algorithm is included into standard C++ library in <random> header file.
The cleaner goal is, obviously, move to every stone on the field, pick it and utilize into trash which also has random coordinates.
After program starts on screen appears a window containing game world:
Cleaner moves between cells and picks all stones. The cleaner moves by pressing any keyboard key:
The goal is achieved when the last cobblestone is recyclied:
To install this project on the computer it's necessary to download and install ROS2 and PlanSys2 on preffered operating system. After that it's needful to make sure that the g++ compiler is available on target system. Plus, SFML library is also required to be installed. This project use both header files of SFML library (.hpp) (to compile the project) and shared libraries of SFML lib directory (.so on Unix and .dll on Windows) (to successfully link all object files in this project).
SFML sources you can find at https://github.com/SFML/SFML repository. ROS2 Humble installation guide is here: https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html. PlanSys2 instructions and theoretical materials are over there: https://plansys2.github.io/getting_started/index.html. You can also visit my Russian-language site: http://matesspace.h1n.ru/articles/ros/ros0/ros0.php.
Thanks for your attention and have a nice time! :)