12#ifndef WSFADVANCEDBEHAVIORTREE_HPP
13#define WSFADVANCEDBEHAVIORTREE_HPP
15#include "wsf_export.h"
43 UtScriptContext*
GetContext(
void* aObjectPtr)
override;
76 void AddBlackboard(
const std::string& aName, std::shared_ptr<WsfAttributeContainer> aBlackboardPtr);
100 const size_t NodeCount()
const {
return mBehaviorNodes.size(); }
106 const std::string&
GetName()
const {
return mName; }
112 static void Reset() { mNextUniqueId = 0; }
125 bool ProcessInput(UtInput& aInput)
override;
133 std::shared_ptr<WsfAdvancedBehaviorTreeCompositeNode>
RootNode()
const {
return mRootNodePtr; }
138 const bool SharedBlackboardExists(
const std::string& aName)
const;
148 bool Tick(
double aSimTime);
158 void FindLastExecuted(std::vector<WsfAdvancedBehaviorTreeNode*>& aLastExecuted)
const;
164 const char* GetScriptClassName()
const override;
180 void SetRootNodeClass();
185 void OutputTreeStructure(
const double aSimTime);
190 void OutputTreeState(
const double aSimTime);
200 void SetThreshold(
const unsigned int aThreshold) { mThreshold = aThreshold; }
204 UtScriptContext* GetScriptAccessibleContext()
const override;
210 bool RegisterExternVariable(
const std::string& aVariableType,
const std::string& aVariableName);
216 std::unique_ptr<WsfAdvancedBehaviorTreeNode> CreateNode(UtInput& aInput);
221 bool ProcessTree(UtInput& aInput);
226 const std::string GetFullFilePath(UtInput& aInput)
const;
229 std::unique_ptr<WsfScriptContext> mContextPtr{
nullptr};
230 std::vector<WsfAdvancedBehaviorTreeActionNode*> mBehaviorNodes;
232 std::map<std::string, std::shared_ptr<WsfAttributeContainer>> mBlackboards;
234 WsfScriptProcessor* mParentPtr;
235 std::shared_ptr<WsfAdvancedBehaviorTreeCompositeNode> mRootNodePtr;
237 bool mOutputForBTT{
false};
240 RootNodeType mRootNodeType;
242 unsigned int mThreshold{1};
243 static unsigned int mNextUniqueId;
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Definition WsfAdvancedBehaviorTreeNode.hpp:584
Definition WsfAdvancedBehaviorTreeNode.hpp:138
std::vector< std::string > GetSharedBlackboardNames() const
Get a list of all shared blackboard names.
Definition WsfAdvancedBehaviorTree.cpp:192
void AddBlackboard(const std::string &aName, std::shared_ptr< WsfAttributeContainer > aBlackboardPtr)
Add a blackboard to the blackboard list.
Definition WsfAdvancedBehaviorTree.cpp:117
bool Initialize(double aSimTime, WsfScriptProcessor *aParentPtr, WsfScriptContext *aParentContextPtr=nullptr)
Initialize this tree.
Definition WsfAdvancedBehaviorTree.cpp:208
WsfAdvancedBehaviorTree(const WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTree.cpp:74
void SetSuccessPolicy(const BT::SuccessPolicy aPolicy)
Set the success policy for this node.
Definition WsfAdvancedBehaviorTree.hpp:195
WsfAdvancedBehaviorTree & operator=(const WsfAdvancedBehaviorTree &aRhs)=delete
std::shared_ptr< WsfAdvancedBehaviorTreeCompositeNode > RootNode() const
Return a shared pointer to the root node of this tree.
Definition WsfAdvancedBehaviorTree.hpp:133
void SetShouldOutputNextTick(const bool aValue)
Set if the tree should output node values to the event pipe next tick.
Definition WsfAdvancedBehaviorTree.hpp:143
WsfScriptProcessor * GetParentProcessor() const
Return a pointer to the parent processor of this tree.
Definition WsfAdvancedBehaviorTree.hpp:120
void SetParentContext(WsfScriptContext *aParentContextPtr)
Set the parent script context for this tree.
Definition WsfAdvancedBehaviorTree.hpp:177
WsfAttributeContainer * GetSharedBlackboard(const std::string &aName) const
Get a blackboard with the specified name from the shared list.
Definition WsfAdvancedBehaviorTree.cpp:183
const std::string & GetName() const
Get the name of this tree.
Definition WsfAdvancedBehaviorTree.hpp:106
~WsfAdvancedBehaviorTree() override=default
const size_t NodeCount() const
Return a count of all leaf nodes.
Definition WsfAdvancedBehaviorTree.hpp:100
void SetParent(WsfScriptProcessor *aParentPtr)
Set the parent processor.
Definition WsfAdvancedBehaviorTree.hpp:172
static unsigned int GetUniqueTreeId()
Get a unique int id for this tree.
Definition WsfAdvancedBehaviorTree.hpp:109
static void Reset()
Reset the unique int counter.
Definition WsfAdvancedBehaviorTree.hpp:112
WsfSimulation * GetSimulation()
Return a pointer to the simulation.
Definition WsfAdvancedBehaviorTree.cpp:202
const unsigned int & GetTreeId() const
Get the id of this tree.
Definition WsfAdvancedBehaviorTree.hpp:103
void SetThreshold(const unsigned int aThreshold)
Set the threshold(number) of children that must succeed for this node to succeed.
Definition WsfAdvancedBehaviorTree.hpp:200
const WsfScriptContext & GetScriptContext() const
Returns a reference to the script context for this tree.
Definition WsfAdvancedBehaviorTree.hpp:167
Definition WsfAttributeContainer.hpp:24
WsfObject()
This is the constructor for the WsfObject class.
Definition WsfObject.cpp:88
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
WsfScriptAdvancedBehaviorTreeClass(const std::string &aClassName, UtScriptTypes *aScriptTypesPtr)
Definition WsfAdvancedBehaviorTree.cpp:25
UT_DECLARE_SCRIPT_METHOD(Id)
UT_DECLARE_SCRIPT_METHOD(RootNode)
UT_DECLARE_SCRIPT_METHOD(FindNode)
UT_DECLARE_SCRIPT_METHOD(Name)
UtScriptContext * GetContext(void *aObjectPtr) override
Return a pointer to the script context for an object.
Definition WsfAdvancedBehaviorTree.cpp:36
Definition WsfScriptContext.hpp:71
void * Clone(void *aObjectPtr) override
Definition WsfScriptObjectClass.cpp:50
WsfScriptObjectClass(const std::string &aClassName, UtScriptTypes *aTypesPtr)
Definition WsfScriptObjectClass.cpp:24
Definition WsfScriptProcessor.hpp:43
The main controller for a simulation.
Definition WsfSimulation.hpp:109
SuccessPolicy
Success policy for a Parallel composite node.
Definition WsfAdvancedBehaviorTreeNode.hpp:64
@ cTHRESHOLD
Definition WsfAdvancedBehaviorTreeNode.hpp:67