1 #ifndef GRAIL_PLANNER_H 
    2 #define GRAIL_PLANNER_H 
    4 #include "WorldState/WorldState.hh" 
    5 #include "Action/Action.hh" 
    6 #include "../../GrailData/DebugInfo/PlannerSnapshots.h" 
   18         using ConditionFunction = std::function<bool(
const WorldState&)>;
 
   19         using PlannerHeuristic = std::function<double(
const WorldState&, 
const std::vector<ConditionFunction>&)>;
 
   28                 PlannerHeuristic heuristic = 
nullptr;
 
   29                 std::size_t iterationLimit = 500;
 
   30                 int maxPlanLength = -1;
 
   31                 double maxPlanCost = -1;
 
   32                 std::size_t initialNodeCapacity = 128;
 
   37                 std::vector<Action> actions{};
 
   38                 float totalCost = 0.0f;
 
   44             void SetIterationLimit(std::size_t iterationLimit);
 
   45             void SetMaxPlanLength(
int maxLength);
 
   46             void SetMaxPlanCost(
double maxCost);
 
   47             void SetHeuristic(PlannerHeuristic heuristic);
 
   48             void ResetConfig(
const Config& config);
 
   53             AbstractPlan GetPartialPlan() 
const;
 
   55             void Iterate(std::size_t iterationCount) noexcept;
 
   56             void IterateWithSnapshot(std::size_t iterationCount, 
PlannerReasonerSnapshot& snapshot, std::size_t minDebugSnapshotIteration = 0, std::size_t maxDebugSnapshotIteration = std::numeric_limits<std::size_t>::max()) noexcept;
 
   57             void SetPlanFoundCallback(const std::function<
void(const AbstractPlan&)> callbackFunction);
 
   58             void SetPlanningFailedCallback(const std::function<
void()> callbackFunction);
 
   60             bool IsComputing() const;
 
   71                 double distanceFromGoal = std::numeric_limits<double>::max();
 
   72                 std::shared_ptr<Edge> pathEdge = 
nullptr;
 
   74                 Node(Node&& other) noexcept;
 
   77                 Node& operator=(Node&& other) noexcept;
 
   82                 Edge(std::size_t sourceIndex, std::size_t destinationIndex, 
Action&& action);
 
   83                 Edge(Edge&& otherEdge) = 
default;
 
   85                 std::size_t sourceIndex = 0;
 
   86                 std::size_t destinationIndex = 0;
 
   92                 EdgePriority(
const std::shared_ptr<Edge>& edge, 
double dijkstraScore, 
double aStarScore);
 
   94                 std::shared_ptr<Edge> edge;
 
   99             class EdgePriorityComparer
 
  102                 bool operator() (
const EdgePriority& one, 
const EdgePriority& other)
 
  104                     return one.aStarScore > other.aStarScore;
 
  109             void AddNode(Node&& node);
 
  110             bool IsGoalAchieved(
const WorldState& state) 
const;
 
  112             WorldState initialState;
 
  113             Config plannerConfig = {};
 
  115             std::vector<ConditionFunction> goalConditions = {};
 
  116             std::function<void(
const AbstractPlan&)> onPlanFound = 
nullptr;
 
  117             std::function<void()> onPlanningFailed = 
nullptr;
 
  120             std::size_t nextNodeIndex = 0;
 
  121             std::size_t nodeClosestToGoalIndex = std::numeric_limits<std::size_t>::max();
 
  122             std::size_t lastChosenNodeIndex = std::numeric_limits<std::size_t>::max();
 
  123             int maxNodeDepth = 0;
 
  124             std::priority_queue<EdgePriority, std::vector<EdgePriority>, EdgePriorityComparer> edges{};
 
  125             std::vector<Node> generatedNodes{};
 
  126             std::vector<std::size_t> closedNodeIndices{};
 
  127             std::size_t currentIteration = 0;
 
  128             bool isPlanningFinished = 
true;
 
The MemoryPool class - preallocated memory container for optimization issues.
Definition: MemoryPool.hh:74
The main class responsible for finding paths in plan space.
Definition: Planner.hh:23
void PushCondition(ConditionFunction condition)
Definition: Planner.cpp:58
A class representing planner world state.
Definition: WorldState.hh:15
Definition: PlannerSnapshots.h:50
Definition: PlannerSnapshots.h:70
Definition: Planner.hh:36
Definition: Planner.hh:26