1 #ifndef GRAIL_PLANNER_REASONER_H
2 #define GRAIL_PLANNER_REASONER_H
4 #include "../GoalSelector.hh"
5 #include "../../GrailCore/Behavior.hh"
6 #include "../../GrailCore/Plan.hh"
7 #include "../../GrailCore/Reasoner.hh"
8 #include "../../GrailData/DebugInfo/PlannerSnapshots.h"
12 using PlannerCallback = std::function<void(
const planning::Plan&,
const planning::Goal&)>;
16 class DomainTranslator;
29 std::size_t maxIterations = 1000;
30 int maxPlanLength = -1;
31 std::size_t iterationsPerFrame = 10;
32 double maxPlanCost = -1;
33 bool usePartialPlans =
true;
38 std::shared_ptr<planning::GoalSelector> goalSelector,
39 std::unique_ptr<planning::DomainTranslator> domainTranslator,
42 virtual void SetNewGoal(std::unique_ptr<planning::Goal> newGoal,
AIEntity& entity)
override;
47 void SetupNewPlanner(std::unique_ptr<planning::DomainTranslator> domainTranslator,
const Config& config);
55 void BindPlanningSucceededCallback(PlannerCallback callback);
56 void BindPartialPlanFoundCallback(PlannerCallback callback);
57 void BindPlanningFailedCallback(std::function<
void(
const planning::Goal&)> callback);
58 void BindPlanExecutedCallback(std::function<
void()> callback);
62 void SetSnapshotProduction(
bool shouldProduce);
63 bool IsComputing()
const;
66 virtual std::unique_ptr<ISnapshotGenerator> CreateSnapshotGenerator(std::size_t)
override;
67 void ClearCurrentDebugSnapshot();
69 void SetDebugSnapshotFirstIteration(std::size_t iterationNumber);
70 void SetDebugSnapshotLastIteration(std::size_t iterationNumber);
71 std::size_t GetDebugSnapshotFirstIteration()
const;
72 std::size_t GetDebugSnapshotLastIteration()
const;
78 std::shared_ptr<planning::GoalSelector> goalSelector;
79 std::unique_ptr<planning::DomainTranslator> domainTranslator;
80 std::unique_ptr<MemoryPool> memory;
83 std::size_t iterationsPerFrame = 0;
84 bool usePartialPlans =
false;
86 std::unique_ptr<planning::Goal> chosenGoal =
nullptr;
87 std::unique_ptr<Behavior> fallbackBehavior =
nullptr;
89 PlannerCallback onPlanningSucceeded;
90 PlannerCallback onPartialPlanFound;
92 std::function<void()> onPlanExecuted;
96 bool produceSnapshot =
false;
99 std::size_t debugSnapshotFirstIteration = 0;
100 std::size_t debugSnapshotLastIteration = std::numeric_limits<std::size_t>::max();
103 #endif //GRAIL_PLANNER_REASONER_H