WSF
WsfAdvancedBehaviorTreeNode.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2021 Infoscitex, a DCS Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef WSFADVANCEDBEHAVIORTREENODE_HPP
13#define WSFADVANCEDBEHAVIORTREENODE_HPP
14
15#include "wsf_export.h"
16
17#include <string>
18#include <vector>
19
20#include "UtColor.hpp"
21#include "WsfEventPipeClasses.hpp"
22#include "WsfObject.hpp"
23#include "WsfObjectTypeList.hpp"
25
26class UtInput;
29class WsfMessage;
30class WsfPlatform;
31class WsfScript;
36class WsfSimulation;
37
92
94{
95public:
96 WsfScriptAdvancedBehaviorTreeNodeClass(const std::string& aClassName, UtScriptTypes* aScriptTypesPtr);
97
101 UtScriptContext* GetContext(void* aObjectPtr) override;
102
103 // Script methods
104 // Each of the exported methods are defined as function objects.
117
118 // Blackboard methods
119 UT_DECLARE_SCRIPT_METHOD(BlackboardVarExists);
120 UT_DECLARE_SCRIPT_METHOD(CreateSharedBlackboard);
121 UT_DECLARE_SCRIPT_METHOD(DeleteBlackboardVar);
122 UT_DECLARE_SCRIPT_METHOD(DeleteSharedBlackboardVar);
123 UT_DECLARE_SCRIPT_METHOD(GetBlackboardVar);
124 UT_DECLARE_SCRIPT_METHOD(GetSharedBlackboardVar);
125 UT_DECLARE_SCRIPT_METHOD(SetBlackboardVar);
126 UT_DECLARE_SCRIPT_METHOD(SetBlackboardTrackVar);
127 UT_DECLARE_SCRIPT_METHOD(SetBlackboardPlatformVar);
128 UT_DECLARE_SCRIPT_METHOD(SetSharedBlackboardVar);
129 UT_DECLARE_SCRIPT_METHOD(SetSharedBlackboardTrackVar);
130 UT_DECLARE_SCRIPT_METHOD(SetSharedBlackboardPlatformVar);
131 UT_DECLARE_SCRIPT_METHOD(ShareBlackboard);
132 UT_DECLARE_SCRIPT_METHOD(ShareBlackboardWithName);
133 UT_DECLARE_SCRIPT_METHOD(SharedBlackboardExists);
134 UT_DECLARE_SCRIPT_METHOD(SharedBlackboardVarExists);
135};
136
138{
139public:
144
148 virtual void AddChild(std::shared_ptr<WsfAdvancedBehaviorTreeNode> aNodePtr) {}
149
153 virtual void AddTree(ut::CloneablePtr<WsfAdvancedBehaviorTree>& aTreePtr) {}
154
156 virtual std::vector<std::shared_ptr<WsfAdvancedBehaviorTreeNode>>& GetChildren()
157 {
158 throw std::logic_error("This node doesn't have children!");
159 }
160
162 virtual std::map<size_t, ut::CloneablePtr<WsfAdvancedBehaviorTree>>& GetTrees()
163 {
164 throw std::logic_error("This node doesn't have children trees!");
165 }
166
168 virtual void OutputTreeStructures(const double aSimTime) {}
169
171 virtual void OutputTreeStates(const double aSimTime) {}
172
174 WsfAdvancedBehaviorTreeNode* Clone() const override = 0;
175
177 virtual const int GetDepth() const { return 0; }
178
180 const time_t& GetFileLastModTime() const { return mFileLastModTime; }
181
183 const std::string& GetFilePath() const { return mFullPathFileName; }
184
186 std::shared_ptr<WsfAttributeContainer> GetBlackboard() { return mBlackboard; }
187
189 const std::string& GetNodeName() const { return mName; }
190
194 void SetNodeName(const std::string& aName);
195
197 const std::string& GetDescription() const { return mDescription; }
198
202 void SetDescription(const std::string& aDesc) { mDescription = aDesc; }
203
206
208 const WsfScenario& GetScenario() const { return mScenario; }
209
211 const char* GetScriptClassName() const override;
212
215
217 WsfSimulation* GetSimulation() const;
218
220 const std::string& GetPreconditionTooltip() const { return mPreconditionTooltip; }
221
223 const std::string& GetExecuteTooltip() const { return mExecuteTooltip; }
224
226 const bool& GetTurnedOn() const { return mTurnedOn; };
227
229 static unsigned int GetUniqueNodeId() { return ++mNextUniqueId; }
230
234 virtual void Halt(const std::string& aReason) {}
235
240 virtual void HaltChildren(unsigned int aIndex, const std::string& aReason) {}
241
243 virtual const bool HasChildrenContainer() const { return false; };
244
246 const bool& HasParent() const { return mHasParent; }
247
249 const unsigned int& Id() const { return mId; }
250
252 const UtColor& GetColor() const { return mColor; }
253
255 bool HasDefinedColor() const { return mHasDefinedColor; }
256
261 virtual bool Initialize(double aSimTime, WsfScriptContext* aParentContextPtr);
262
264 WsfPlatform* GetOwningPlatform() const;
265
267 WsfScriptProcessor* GetOwningProcessor() const;
268
270 WsfAdvancedBehaviorTree* GetOwningTree() const;
271
274
276 const bool PreconditionsMet() const;
277
282 virtual const double PreconditionValue() const { return 0.0; }
283
287 bool ProcessInput(UtInput& aInput) override;
288
293 virtual bool ProcessMessage(double aSimTime, const WsfMessage& aMessage);
294
298 virtual void RegisterInput(UtInput& aInput) {}
299
301 static void Reset() { mNextUniqueId = 0; }
302
306 virtual void ResetPreconditionVars() {}
307
311 void SetFilePath(const std::string& aPath);
312
316 void SetHasParent(const bool aValue);
317
321 void SetParent(WsfAdvancedBehaviorTreeNode* aNodePtr) { mParentPtr = aNodePtr; }
322
327 void SetTooltip(const std::string& aText, const bool aSendEvent = false);
328
333 void SetPreconditionTooltip(const std::string& aText, const bool aSendEvent = false);
334
339 void SetExecuteTooltip(const std::string& aText, const bool aSendEvent = false);
340
344 virtual void SetTree(WsfAdvancedBehaviorTree* aTreePtr){};
345
347 virtual BT::ReturnStatus Tick();
348
353
355 virtual void TurnOff(){};
356
358 virtual void TurnOn(){};
359
360 bool ExecutedLastTick() const { return mExecutedLastTick; }
361
366 WsfAdvancedBehaviorTreeNode* FindNode(const std::string& aNodeName);
367
371 void FindLastExecuted(std::vector<WsfAdvancedBehaviorTreeNode*>& aLastExecuted);
372
376 void SetIsTreeRootNode(const bool aState) { mIsTreeRootNode = aState; }
377
379 bool GetIsTreeRootNode() const { return mIsTreeRootNode; }
380
382
384 WsfAdvancedBehaviorTreeNode* GetTopRootNode();
385
387 UtScript* GetExecuteScript() { return mExecuteScriptPtr; }
388
389 void SetInitScript(UtScript* aScriptPtr);
390
391protected:
396 bool RegisterExternVariable(const std::string& aVariableType, const std::string& aVariableName);
397
399 UtScriptContext* GetScriptAccessibleContext() const override;
400
405 void SetFileInfo(const std::string& aPath, const time_t& aModTime);
406
410 void SetNodeStatus(const BT::ReturnStatus aStatus);
411
412 //* Unique integer id of this node
413 unsigned int mId{0};
414
415 //* Scenario of this node
417
418 //* Blackboard for writing and reading script variables
419 std::shared_ptr<WsfAttributeContainer> mBlackboard;
420
421 //* Pointer to the script context of this node
423
424 //* Pointer to the script message handler for this node
426
427 //* Pointer to the parent node of this node
429
430 //* Pointer to the tree that parents this node
432
433 //* Pointer to the finite state machine for this node.
435
436 //* Integer representing the current state the finite state machine is in
438
439 //* Timestamp representing the last time the script file this node was declared in was modified
441
442 //* True if debugging is turned on for this node, false otherwise
443 bool mDebug{false};
444
445 //* True if this node is initialized, false otherwise
446 bool mInitialized{false};
447
448 //* True if this node is turned on, false otherwise
449 bool mTurnedOn{true};
450
451 //* Consider this node as another tree?
452 bool mIsTreeRootNode{false};
453
454 //* True if this node has a parent, false otherwise
455 bool mHasParent{false};
456
457 //* True if the node ran the execute block last tick. This is used for on_new_failure and on_new_execute.
458 bool mExecutedLastTick{false};
459
460 //* True if the node is in its precondition block, false otherwise. Used to determine which tooltip from script funcs.
461 mutable bool mInPrecondition{false};
462
463 //* True if the precondition has run for the node this tick, false otherwise.
464 mutable bool mPreconditionRan{false};
465
466 //* True if the node's precondition has been met(>0.0), false otherwise. Used in determining whether or not to tick a node
467 //* when it's precondition has been skipped for selectors, selectors with memory, and parallel composite nodes.
468 mutable bool mPreconditionMet{false};
469
470 //* ReturnStatus of the node
472
473 //* Full file path to the script file this node was declared in
474 std::string mFullPathFileName{""};
475
476 //* Name of the node
477 std::string mName{""};
478
479 //* Description of the node
480 std::string mDescription{""};
481
482 //* Tooltip text for the precondition script block
483 std::string mPreconditionTooltip{""};
484
485 //* Tooltip text fsor the execute script block
486 std::string mExecuteTooltip{""};
487
488 //* Time representing when the tooltip text was set
490
491 //* Time representing when the tooltip text was set
493
494 //* Pointer to the initialization script for this node
495 UtScript* mOnInitScriptPtr{nullptr};
496
497 //* Pointer to a new execute script
498 UtScript* mNewExecuteScriptPtr{nullptr};
499
500 //* Pointer to a new fail script
501 UtScript* mNewFailScriptPtr{nullptr};
502
503 //* Pointer to the precondition script of this node
504 UtScript* mPreconditionScriptPtr{nullptr};
505
506 //* Pointer to the execute script for this node
507 UtScript* mExecuteScriptPtr{nullptr};
508
509 //* The color to set Platform History trace lines
510 UtColor mColor;
511
512 //* True if the color was defined through user input, false otherwise
514
515private:
516 //* Counter for unique node ids
517 static unsigned int mNextUniqueId;
518};
519
520class WsfAdvancedBehaviorTreeNodeTypes : public WsfObjectTypeList<WsfAdvancedBehaviorTreeNode>
521{
522public:
524
528 LoadResult LoadType(UtInput& aInput) override;
529};
530
532{
533public:
537
539 WsfAdvancedBehaviorTreeLeafNode* Clone() const override;
540
542 const int GetDepth() const override { return 0; }
543
547 void Halt(const std::string& aReason) override;
548
553 const double PreconditionValue() const override;
554
558 bool ProcessInput(UtInput& aInput) override;
559
563 void RegisterInput(UtInput& aInput) override;
564
566 void TurnOff() override;
567
569 void TurnOn() override;
570
574 void ResetPreconditionVars() override;
575
576protected:
580 void SetTree(WsfAdvancedBehaviorTree* aTreePtr) override;
581};
582
584{
585public:
586 explicit WsfAdvancedBehaviorTreeActionNode(const WsfScenario& aScenario);
588
591
595 void Halt(const std::string& aReason) override;
596
600 void SetTree(WsfAdvancedBehaviorTree* aTreePtr) override;
601
603 BT::ReturnStatus Tick() override;
604};
605
607{
608public:
609 explicit WsfAdvancedBehaviorTreeConditionNode(const WsfScenario& aScenario);
611
614
618 void Halt(const std::string& aReason) override;
619
621 BT::ReturnStatus Tick() override;
622};
623
625{
626public:
631
634
638 void AddChild(std::shared_ptr<WsfAdvancedBehaviorTreeNode> aChildPtr) override;
639
643 void AddTree(ut::CloneablePtr<WsfAdvancedBehaviorTree>& aTreePtr) override;
644
646 std::vector<std::shared_ptr<WsfAdvancedBehaviorTreeNode>>& GetChildren() override { return mChildren; }
647
649 std::map<size_t, ut::CloneablePtr<WsfAdvancedBehaviorTree>>& GetTrees() override { return mTrees; }
650
652 void OutputTreeStructures(const double aSimTime) override;
653
655 void OutputTreeStates(const double aSimTime) override;
656
658 const int GetDepth() const override;
659
663 void Halt(const std::string& aReason) override;
664
666 const bool HasChildrenContainer() const override { return true; };
667
672 bool Initialize(double aSimTime, WsfScriptContext* aParentContextPtr) override;
673
678 const double PreconditionValue() const override;
679
683 void SetTree(WsfAdvancedBehaviorTree* aTreePtr) override;
684
686 void TurnOff() override;
687
689 void TurnOn() override;
690
695 void ResetPreconditionVars() override;
696
697protected:
699 const bool AreChildrenRunning() const;
700
702 const unsigned int GetLastEnabledChild() const;
703
705 const unsigned int GetNumEnabledChildren() const;
706
711 void HaltChildren(unsigned int aIndex, const std::string& aReason) override;
712
716 void HaltRunning(const std::string& aReason);
717
718 //* List of children nodes
719 std::vector<std::shared_ptr<WsfAdvancedBehaviorTreeNode>> mChildren;
720
721 //* Map of indices to trees, where the index is the slot of the root node in the children.
722 std::map<size_t, ut::CloneablePtr<WsfAdvancedBehaviorTree>> mTrees;
723};
724
726{
727public:
728 explicit WsfAdvancedBehaviorTreeDecoratorNode(const WsfScenario& aScenario);
730
734 void AddChild(std::shared_ptr<WsfAdvancedBehaviorTreeNode> aChildPtr) override;
735
739 void AddTree(ut::CloneablePtr<WsfAdvancedBehaviorTree>& aTreePtr) override;
740
742 void OutputTreeStructures(const double aSimTime) override;
743
745 void OutputTreeStates(const double aSimTime) override;
746
749
752};
753
772
785
787{
788public:
789 explicit WsfAdvancedBehaviorTreeNegatorNode(const WsfScenario& aScenario);
791
794
798 const double PreconditionValue() const override { return 0.0; }
799
801 BT::ReturnStatus TickFunction() override;
802};
803
805{
806public:
818
819 explicit WsfAdvancedBehaviorTreeRepeaterNode(const WsfScenario& aScenario);
821
824
826 int& GetRepeats() { return mRepeats; }
827
829 double& GetRunDuration() { return mRunDuration; }
830
833
837 void SetRepeats(const int aRepeatCount);
838
842 void SetRunType(const RunType aRunType);
843
845 BT::ReturnStatus TickFunction() override;
846
847protected:
848 //* How many times to repeat this node
850
851 //* Number of repeats left before defaulting to failure
853
854 //* How long to run this node before defaulting to failure
856
857 //* Time representing when the node started running (used for checking time)
859
860 //* Run type of this node (Repeater Decorator)
862};
863
865{
866public:
867 explicit WsfAdvancedBehaviorTreeParallelNode(const WsfScenario& aScenario);
869 BT::SuccessPolicy aSuccessPolicy = BT::cSUCCEED_ON_ONE,
870 const unsigned int aThreshold = 0);
872
875
879 void Halt(const std::string& aReason) override;
880
885 const double PreconditionValue() const override;
886
890 bool ProcessInput(UtInput& aInput) override;
891
894
895private:
897 BT::SuccessPolicy GetSuccessPolicy() const { return mPolicy; }
898
900 const unsigned int& GetThreshold() const { return mThreshold; }
901
905 void SetSuccessPolicy(const BT::SuccessPolicy aPolicy);
906
910 void SetThreshold(const unsigned int aThreshold);
911
912 //* Number of children that have failed
913 unsigned int mNumChildrenFailure = 0;
914
915 //* Number of children that have succeeded
916 unsigned int mNumChildrenSuccess = 0;
917
918 //* Policy for handling when a parallel node should return success
920
921 //* Threshold needed for this node to succeed
922 unsigned int mThreshold = 1;
923};
924
944
946{
947public:
948 explicit WsfAdvancedBehaviorTreeSelectorNodeWithMemory(const WsfScenario& aScenario, BT::ResetPolicy aResetPolicy);
950 BT::ResetPolicy aResetPolicy);
952
955
959 void Halt(const std::string& aReason) override;
960
965 const double PreconditionValue() const override;
966
969
970private:
971 //* Current child we are skipping to
972 unsigned int mCurrentChildIndex;
973
974 //* Reset policy for this Sequence
975 BT::ResetPolicy mResetPolicy;
976};
977
991
993{
994public:
995 explicit WsfAdvancedBehaviorTreeSequenceNodeWithMemory(const WsfScenario& aScenario, BT::ResetPolicy aResetPolicy);
997 BT::ResetPolicy aResetPolicy);
999
1002
1006 void Halt(const std::string& aReason) override;
1007
1009 BT::ReturnStatus TickFunction() override;
1010
1011private:
1012 //* Current child we are skipping to
1013 unsigned int mCurrentChildIndex;
1014
1015 //* Reset policy for this Sequence
1016 BT::ResetPolicy mResetPolicy;
1017};
1018
1020{
1021public:
1025
1028
1034 const double PreconditionValue() const override;
1035
1037 BT::ReturnStatus TickFunction() override;
1038
1039private:
1041 WsfAdvancedBehaviorTreeNode* GetCurrentSelection() const { return mCurrentSelectionPtr; }
1042
1046 void SetCurrentSelection(WsfAdvancedBehaviorTreeNode* aNodePtr) { mCurrentSelectionPtr = aNodePtr; }
1047
1048 //* Pointer to the currently selected node. If a node is selected, the priority selector won't check weights on tick.
1049 mutable WsfAdvancedBehaviorTreeNode* mCurrentSelectionPtr;
1050};
1051
1053{
1054public:
1055 explicit WsfAdvancedBehaviorTreeWeightedRandomNode(const WsfScenario& aScenario);
1058
1061
1067 const double PreconditionValue() const override;
1068
1070 BT::ReturnStatus TickFunction() override;
1071
1072private:
1074 const std::pair<double, WsfAdvancedBehaviorTreeNode*> GetRandomNode() const;
1075
1076 //* Pointer to the weighted random node that was chosen on draw during the PreconditionValue() call
1077 mutable WsfAdvancedBehaviorTreeNode* mCurrentSelectionPtr;
1078};
1079#endif
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
BT::ReturnStatus Tick() override
Ticks the node.
Definition WsfAdvancedBehaviorTreeNode.cpp:1321
WsfAdvancedBehaviorTreeActionNode & operator=(const WsfAdvancedBehaviorTreeActionNode &aRhs)=delete
WsfAdvancedBehaviorTreeActionNode(const WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTreeNode.cpp:1300
void Halt(const std::string &aReason) override
Halt this node.
Definition WsfAdvancedBehaviorTreeNode.cpp:1310
void SetTree(WsfAdvancedBehaviorTree *aTreePtr) override
Set the owning tree for this node.
Definition WsfAdvancedBehaviorTreeNode.cpp:1315
Definition WsfAdvancedBehaviorTreeNode.hpp:625
~WsfAdvancedBehaviorTreeCompositeNode() override=default
void AddTree(ut::CloneablePtr< WsfAdvancedBehaviorTree > &aTreePtr) override
Add a tree child to this node.
Definition WsfAdvancedBehaviorTreeNode.cpp:1481
std::map< size_t, ut::CloneablePtr< WsfAdvancedBehaviorTree > > & GetTrees() override
Return a list of current children trees held by this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:649
std::vector< std::shared_ptr< WsfAdvancedBehaviorTreeNode > > mChildren
Definition WsfAdvancedBehaviorTreeNode.hpp:719
void AddChild(std::shared_ptr< WsfAdvancedBehaviorTreeNode > aChildPtr) override
Add a child to this node.
Definition WsfAdvancedBehaviorTreeNode.cpp:1470
std::map< size_t, ut::CloneablePtr< WsfAdvancedBehaviorTree > > mTrees
Definition WsfAdvancedBehaviorTreeNode.hpp:722
WsfAdvancedBehaviorTreeCompositeNode(const WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTreeNode.cpp:1437
const bool HasChildrenContainer() const override
Get if this node can have children.
Definition WsfAdvancedBehaviorTreeNode.hpp:666
std::vector< std::shared_ptr< WsfAdvancedBehaviorTreeNode > > & GetChildren() override
Return a list of current children held by this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:646
WsfAdvancedBehaviorTreeCompositeNode & operator=(const WsfAdvancedBehaviorTreeCompositeNode &)=delete
void Halt(const std::string &aReason) override
Halt this node.
Definition WsfAdvancedBehaviorTreeNode.cpp:1406
WsfAdvancedBehaviorTreeConditionNode & operator=(const WsfAdvancedBehaviorTreeConditionNode &aRhs)=delete
WsfAdvancedBehaviorTreeConditionNode(const WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTreeNode.cpp:1396
BT::ReturnStatus Tick() override
Tick this node.
Definition WsfAdvancedBehaviorTreeNode.cpp:1411
void OutputTreeStates(const double aSimTime) override
Output this nodes tree states to the event pipe if they are outputting.
Definition WsfAdvancedBehaviorTreeNode.cpp:1725
WsfAdvancedBehaviorTreeDecoratorNode(const WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTreeNode.cpp:1690
BT::ReturnStatus TickFunction() override
Tick forward and update the execution of this node and its child.
Definition WsfAdvancedBehaviorTreeNode.cpp:1743
void AddChild(std::shared_ptr< WsfAdvancedBehaviorTreeNode > aChildPtr) override
Add a child to this node.
Definition WsfAdvancedBehaviorTreeNode.cpp:1695
void OutputTreeStructures(const double aSimTime) override
Output this nodes children trees structures to the event pipe.
Definition WsfAdvancedBehaviorTreeNode.cpp:1712
WsfAdvancedBehaviorTreeDecoratorNode & operator=(const WsfAdvancedBehaviorTreeDecoratorNode &aRhs)=delete
void AddTree(ut::CloneablePtr< WsfAdvancedBehaviorTree > &aTreePtr) override
Add a tree child to this node.
Definition WsfAdvancedBehaviorTreeNode.cpp:1706
BT::ReturnStatus TickFunction() override
Tick forward and update the execution of this node and its child.
Definition WsfAdvancedBehaviorTreeNode.cpp:1791
WsfAdvancedBehaviorTreeInverterNode & operator=(const WsfAdvancedBehaviorTreeInverterNode &aRhs)=delete
WsfAdvancedBehaviorTreeInverterNode(const WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTreeNode.cpp:1763
WsfAdvancedBehaviorTreeLeafNode(const WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTreeNode.cpp:1163
const int GetDepth() const override
Return the depth of this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:542
WsfAdvancedBehaviorTreeLeafNode & operator=(const WsfAdvancedBehaviorTreeLeafNode &aRhs)=delete
WsfAdvancedBehaviorTreeNegatorNode & operator=(const WsfAdvancedBehaviorTreeNegatorNode &aRhs)=delete
const double PreconditionValue() const override
Returns a fitness value representing how important this node is.
Definition WsfAdvancedBehaviorTreeNode.hpp:798
WsfAdvancedBehaviorTreeNegatorNode(const WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTreeNode.cpp:1847
LoadResult LoadType(UtInput &aInput) override
Load a new type object from an input stream.
Definition WsfAdvancedBehaviorTreeNode.cpp:559
WsfAdvancedBehaviorTreeNodeTypes(WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTreeNode.cpp:549
Definition WsfAdvancedBehaviorTreeNode.hpp:138
virtual void TurnOn()
Turns this node on.
Definition WsfAdvancedBehaviorTreeNode.hpp:358
WsfAdvancedBehaviorTreeNode & operator=(const WsfAdvancedBehaviorTreeNode &)=delete
std::string mFullPathFileName
Definition WsfAdvancedBehaviorTreeNode.hpp:474
UtScript * mPreconditionScriptPtr
Definition WsfAdvancedBehaviorTreeNode.hpp:504
UtScript * GetExecuteScript()
Return a pointer to the execute script for this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:387
bool mInPrecondition
Definition WsfAdvancedBehaviorTreeNode.hpp:461
UtColor mColor
Definition WsfAdvancedBehaviorTreeNode.hpp:510
const WsfScenario & GetScenario() const
Return the current scenario.
Definition WsfAdvancedBehaviorTreeNode.hpp:208
const std::string & GetFilePath() const
Return the file path to the script this node was declared in.
Definition WsfAdvancedBehaviorTreeNode.hpp:183
time_t mFileLastModTime
Definition WsfAdvancedBehaviorTreeNode.hpp:440
virtual void SetTree(WsfAdvancedBehaviorTree *aTreePtr)
Set the owning tree for this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:344
bool mHasParent
Definition WsfAdvancedBehaviorTreeNode.hpp:455
bool mHasDefinedColor
Definition WsfAdvancedBehaviorTreeNode.hpp:513
virtual void OutputTreeStructures(const double aSimTime)
Output this nodes children trees structures to the event pipe.
Definition WsfAdvancedBehaviorTreeNode.hpp:168
WsfAdvancedBehaviorTreeNode * mParentPtr
Definition WsfAdvancedBehaviorTreeNode.hpp:428
UtScript * mNewFailScriptPtr
Definition WsfAdvancedBehaviorTreeNode.hpp:501
bool mIsTreeRootNode
Definition WsfAdvancedBehaviorTreeNode.hpp:452
const std::string & GetPreconditionTooltip() const
Return the current precondition tooltip text for this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:220
std::string mExecuteTooltip
Definition WsfAdvancedBehaviorTreeNode.hpp:486
virtual void AddChild(std::shared_ptr< WsfAdvancedBehaviorTreeNode > aNodePtr)
Add a child to this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:148
const bool & GetTurnedOn() const
Returns if this node is on.
Definition WsfAdvancedBehaviorTreeNode.hpp:226
bool mPreconditionRan
Definition WsfAdvancedBehaviorTreeNode.hpp:464
bool mInitialized
Definition WsfAdvancedBehaviorTreeNode.hpp:446
bool GetIsTreeRootNode() const
Get if this tree is a root node for a tree.
Definition WsfAdvancedBehaviorTreeNode.hpp:379
bool ExecutedLastTick() const
Definition WsfAdvancedBehaviorTreeNode.hpp:360
std::shared_ptr< WsfAttributeContainer > GetBlackboard()
Return a pointer to the blackboard for this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:186
virtual void TurnOff()
Turns this node off.
Definition WsfAdvancedBehaviorTreeNode.hpp:355
virtual const bool HasChildrenContainer() const
Get if this node can have children.
Definition WsfAdvancedBehaviorTreeNode.hpp:243
WsfAdvancedBehaviorTreeNode(const WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTreeNode.cpp:640
const bool & HasParent() const
Get if this node has a parent.
Definition WsfAdvancedBehaviorTreeNode.hpp:246
virtual void ResetPreconditionVars()
Reset the precondition ran and met var to false at the beginning of the tree tick.
Definition WsfAdvancedBehaviorTreeNode.hpp:306
void SetDescription(const std::string &aDesc)
Set the description of this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:202
void SetIsTreeRootNode(const bool aState)
Set if this node is the root node for a tree.
Definition WsfAdvancedBehaviorTreeNode.hpp:376
std::shared_ptr< WsfAttributeContainer > mBlackboard
Definition WsfAdvancedBehaviorTreeNode.hpp:419
virtual std::map< size_t, ut::CloneablePtr< WsfAdvancedBehaviorTree > > & GetTrees()
Return a list of current children trees held by this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:162
UtScript * mExecuteScriptPtr
Definition WsfAdvancedBehaviorTreeNode.hpp:507
static unsigned int GetUniqueNodeId()
Get a unique int id for this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:229
WsfScriptContext * mContextPtr
Definition WsfAdvancedBehaviorTreeNode.hpp:422
WsfScriptStateMachine * ChildStateMachine()
Definition WsfAdvancedBehaviorTreeNode.hpp:381
virtual void Halt(const std::string &aReason)
Halt the execution of this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:234
const unsigned int & Id() const
Return the unique id for this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:249
bool HasDefinedColor() const
Return the string representation of this node's color.
Definition WsfAdvancedBehaviorTreeNode.hpp:255
const time_t & GetFileLastModTime() const
Return the last time the script this node was declared in was modified.
Definition WsfAdvancedBehaviorTreeNode.hpp:180
double mExecuteTooltipTimestamp
Definition WsfAdvancedBehaviorTreeNode.hpp:492
WsfAdvancedBehaviorTree * mParentTreePtr
Definition WsfAdvancedBehaviorTreeNode.hpp:431
WsfAdvancedBehaviorTreeNode * GetParent() const
Returns a pointer to the current parent of this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:273
const std::string & GetExecuteTooltip() const
Return the current execute tooltip text for this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:223
const std::string & GetDescription() const
Get the description of this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:197
const WsfScriptContext & GetScriptContext() const
Returns a reference to the script context for this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:214
WsfAdvancedBehaviorTreeNode * Clone() const override=0
Clone this node.
virtual BT::ReturnStatus TickFunction()
This is the functionality ran by each node, e.g how the node handles its tick.
Definition WsfAdvancedBehaviorTreeNode.hpp:352
virtual std::vector< std::shared_ptr< WsfAdvancedBehaviorTreeNode > > & GetChildren()
Return a list of current children held by this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:156
static void Reset()
Reset the unique int counter.
Definition WsfAdvancedBehaviorTreeNode.hpp:301
void SetParent(WsfAdvancedBehaviorTreeNode *aNodePtr)
Set the parent of this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:321
virtual const int GetDepth() const
Get the depth of this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:177
bool mPreconditionMet
Definition WsfAdvancedBehaviorTreeNode.hpp:468
virtual void HaltChildren(unsigned int aIndex, const std::string &aReason)
Halt the execution of this node's children starting at an index.
Definition WsfAdvancedBehaviorTreeNode.hpp:240
int mStateIndex
Definition WsfAdvancedBehaviorTreeNode.hpp:437
WsfScriptStateMachine * mFiniteStateMachinePtr
Definition WsfAdvancedBehaviorTreeNode.hpp:434
WsfScriptMessageHandler * mMessageHandlerPtr
Definition WsfAdvancedBehaviorTreeNode.hpp:425
BT::ReturnStatus mReturnStatus
Definition WsfAdvancedBehaviorTreeNode.hpp:471
virtual void RegisterInput(UtInput &aInput)
Register a file path and last modified time from an input.
Definition WsfAdvancedBehaviorTreeNode.hpp:298
const std::string & GetNodeName() const
Get the name of this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:189
UtScript * mOnInitScriptPtr
Definition WsfAdvancedBehaviorTreeNode.hpp:495
UtScript * mNewExecuteScriptPtr
Definition WsfAdvancedBehaviorTreeNode.hpp:498
double mPreconditionTooltipTimestamp
Definition WsfAdvancedBehaviorTreeNode.hpp:489
std::string mName
Definition WsfAdvancedBehaviorTreeNode.hpp:477
std::string mDescription
Definition WsfAdvancedBehaviorTreeNode.hpp:480
virtual const double PreconditionValue() const
Returns a fitness value representing how well the precondition ran.
Definition WsfAdvancedBehaviorTreeNode.hpp:282
const UtColor & GetColor() const
Return this node's color.
Definition WsfAdvancedBehaviorTreeNode.hpp:252
bool mExecutedLastTick
Definition WsfAdvancedBehaviorTreeNode.hpp:458
const BT::ReturnStatus & GetNodeStatus() const
Get the ReturnStatus of this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:205
virtual void AddTree(ut::CloneablePtr< WsfAdvancedBehaviorTree > &aTreePtr)
Add a tree child to this node.
Definition WsfAdvancedBehaviorTreeNode.hpp:153
unsigned int mId
Definition WsfAdvancedBehaviorTreeNode.hpp:413
virtual void OutputTreeStates(const double aSimTime)
Output this nodes tree states to the event pipe if they are outputting.
Definition WsfAdvancedBehaviorTreeNode.hpp:171
bool mDebug
Definition WsfAdvancedBehaviorTreeNode.hpp:443
bool mTurnedOn
Definition WsfAdvancedBehaviorTreeNode.hpp:449
std::string mPreconditionTooltip
Definition WsfAdvancedBehaviorTreeNode.hpp:483
const WsfScenario & mScenario
Definition WsfAdvancedBehaviorTreeNode.hpp:416
BT::ReturnStatus TickFunction() override
Tick forward and update the execution of this node and its children.
Definition WsfAdvancedBehaviorTreeNode.cpp:2127
WsfAdvancedBehaviorTreeParallelNode & operator=(const WsfAdvancedBehaviorTreeParallelNode &aRhs)=delete
const double PreconditionValue() const override
Returns a fitness value representing how important this node is.
Definition WsfAdvancedBehaviorTreeNode.cpp:2065
void Halt(const std::string &aReason) override
Halt the execution of this node.
Definition WsfAdvancedBehaviorTreeNode.cpp:2056
WsfAdvancedBehaviorTreeParallelNode(const WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTreeNode.cpp:2033
bool ProcessInput(UtInput &aInput) override
Process input from a script.
Definition WsfAdvancedBehaviorTreeNode.cpp:2091
BT::ReturnStatus TickFunction() override
Tick forward and update the execution of this node, and its children.
Definition WsfAdvancedBehaviorTreeNode.cpp:2651
WsfAdvancedBehaviorTreePrioritySelectorNode & operator=(const WsfAdvancedBehaviorTreePrioritySelectorNode &aRhs)=delete
const double PreconditionValue() const override
Returns a fitness value representing how important this node is.
Definition WsfAdvancedBehaviorTreeNode.cpp:2633
WsfAdvancedBehaviorTreePrioritySelectorNode(const WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTreeNode.cpp:2611
Definition WsfAdvancedBehaviorTreeNode.hpp:805
int mRepeats
Definition WsfAdvancedBehaviorTreeNode.hpp:849
RunType & GetRunType()
Get the run type for this repeater node.
Definition WsfAdvancedBehaviorTreeNode.hpp:832
RunType mRunType
Definition WsfAdvancedBehaviorTreeNode.hpp:861
RunType
Run Type of the node.
Definition WsfAdvancedBehaviorTreeNode.hpp:813
@ UntilDone
Definition WsfAdvancedBehaviorTreeNode.hpp:816
@ Repeat
Definition WsfAdvancedBehaviorTreeNode.hpp:814
@ ForTime
Definition WsfAdvancedBehaviorTreeNode.hpp:815
WsfAdvancedBehaviorTreeRepeaterNode & operator=(const WsfAdvancedBehaviorTreeRepeaterNode &aRhs)=delete
double & GetRunDuration()
Returns a reference to the run duration.
Definition WsfAdvancedBehaviorTreeNode.hpp:829
double mRunStartTime
Definition WsfAdvancedBehaviorTreeNode.hpp:858
double mRunDuration
Definition WsfAdvancedBehaviorTreeNode.hpp:855
int & GetRepeats()
Returns a reference to the number of repeats.
Definition WsfAdvancedBehaviorTreeNode.hpp:826
int mRepeatsLeft
Definition WsfAdvancedBehaviorTreeNode.hpp:852
WsfAdvancedBehaviorTreeRepeaterNode(const WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTreeNode.cpp:1880
BT::ReturnStatus TickFunction() override
Tick forward and update the execution of this node, and its children.
Definition WsfAdvancedBehaviorTreeNode.cpp:2383
const double PreconditionValue() const override
Returns a fitness value representing how important this node is.
Definition WsfAdvancedBehaviorTreeNode.cpp:2369
WsfAdvancedBehaviorTreeSelectorNodeWithMemory(const WsfScenario &aScenario, BT::ResetPolicy aResetPolicy)
Definition WsfAdvancedBehaviorTreeNode.cpp:2335
WsfAdvancedBehaviorTreeSelectorNodeWithMemory & operator=(const WsfAdvancedBehaviorTreeSelectorNodeWithMemory &aRhs)=delete
void Halt(const std::string &aReason) override
Halt the execution of this node.
Definition WsfAdvancedBehaviorTreeNode.cpp:2361
WsfAdvancedBehaviorTreeSelectorNode(const WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTreeNode.cpp:2252
const double PreconditionValue() const override
Returns a fitness value representing how important this node is.
Definition WsfAdvancedBehaviorTreeNode.cpp:2271
BT::ReturnStatus TickFunction() override
Tick forward and update the execution of this node, and its children.
Definition WsfAdvancedBehaviorTreeNode.cpp:2285
WsfAdvancedBehaviorTreeSelectorNode & operator=(const WsfAdvancedBehaviorTreeSelectorNode &aRhs)=delete
WsfAdvancedBehaviorTreeSequenceNodeWithMemory(const WsfScenario &aScenario, BT::ResetPolicy aResetPolicy)
Definition WsfAdvancedBehaviorTreeNode.cpp:2515
void Halt(const std::string &aReason) override
Halt the execution of this node.
Definition WsfAdvancedBehaviorTreeNode.cpp:2541
BT::ReturnStatus TickFunction() override
Tick forward and update the execution of this node, and it's children.
Definition WsfAdvancedBehaviorTreeNode.cpp:2549
WsfAdvancedBehaviorTreeSequenceNodeWithMemory & operator=(const WsfAdvancedBehaviorTreeSequenceNodeWithMemory &aRhs)=delete
WsfAdvancedBehaviorTreeSequenceNode & operator=(const WsfAdvancedBehaviorTreeSequenceNode &aRhs)=delete
BT::ReturnStatus TickFunction() override
Tick forward and update the execution of this node, and its children.
Definition WsfAdvancedBehaviorTreeNode.cpp:2465
WsfAdvancedBehaviorTreeSequenceNode(const WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTreeNode.cpp:2446
WsfAdvancedBehaviorTreeSucceederNode(const WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTreeNode.cpp:1814
BT::ReturnStatus TickFunction() override
Tick forward and update the execution of this node, and its child.
Definition WsfAdvancedBehaviorTreeNode.cpp:1827
WsfAdvancedBehaviorTreeSucceederNode & operator=(const WsfAdvancedBehaviorTreeSucceederNode &aRhs)=delete
WsfAdvancedBehaviorTreeWeightedRandomNode & operator=(const WsfAdvancedBehaviorTreeWeightedRandomNode &aRhs)=delete
BT::ReturnStatus TickFunction() override
Tick forward and update the execution of this node, and its children.
Definition WsfAdvancedBehaviorTreeNode.cpp:2831
WsfAdvancedBehaviorTreeWeightedRandomNode(const WsfScenario &aScenario)
Definition WsfAdvancedBehaviorTreeNode.cpp:2761
const double PreconditionValue() const override
Returns a fitness value representing how important this node is.
Definition WsfAdvancedBehaviorTreeNode.cpp:2822
Definition WsfAdvancedBehaviorTree.hpp:54
Definition WsfAttributeContainer.hpp:24
A base class for messages sent among simulation communication objects, processors and sensors.
Definition WsfMessage.hpp:33
WsfObjectTypeList(WsfScenario &aScenario, unsigned int aFlags, const std::string &aBlockName)
Definition WsfObjectTypeList.hpp:76
WsfObject()
This is the constructor for the WsfObject class.
Definition WsfObject.cpp:88
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
UtScriptContext * GetContext(void *aObjectPtr) override
Return a pointer to the script context for an object.
Definition WsfAdvancedBehaviorTreeNode.cpp:84
UT_DECLARE_SCRIPT_METHOD(SetSharedBlackboardVar)
UT_DECLARE_SCRIPT_METHOD(DeleteSharedBlackboardVar)
UT_DECLARE_SCRIPT_METHOD(SetSharedBlackboardPlatformVar)
UT_DECLARE_SCRIPT_METHOD(CreateSharedBlackboard)
UT_DECLARE_SCRIPT_METHOD(SharedBlackboardVarExists)
UT_DECLARE_SCRIPT_METHOD(SetSharedBlackboardTrackVar)
UT_DECLARE_SCRIPT_METHOD(DeleteBlackboardVar)
UT_DECLARE_SCRIPT_METHOD(ShareBlackboardWithName)
UT_DECLARE_SCRIPT_METHOD(GetSharedBlackboardVar)
WsfScriptAdvancedBehaviorTreeNodeClass(const std::string &aClassName, UtScriptTypes *aScriptTypesPtr)
Definition WsfAdvancedBehaviorTreeNode.cpp:40
UT_DECLARE_SCRIPT_METHOD(SetBlackboardPlatformVar)
UT_DECLARE_SCRIPT_METHOD(SetBlackboardTrackVar)
UT_DECLARE_SCRIPT_METHOD(SharedBlackboardExists)
UT_DECLARE_SCRIPT_METHOD(BlackboardVarExists)
Definition WsfScriptContext.hpp:71
Definition WsfScriptMessageHandler.hpp:42
void * Clone(void *aObjectPtr) override
Definition WsfScriptObjectClass.cpp:50
WsfScriptObjectClass(const std::string &aClassName, UtScriptTypes *aTypesPtr)
Definition WsfScriptObjectClass.cpp:24
Definition WsfScriptProcessor.hpp:43
Definition WsfScriptStateMachine.hpp:47
The main controller for a simulation.
Definition WsfSimulation.hpp:109
Definition WsfAdvancedBehaviorTreeNode.hpp:39
ReturnStatus
The return status of a node at a given time step (tick).
Definition WsfAdvancedBehaviorTreeNode.hpp:49
@ cFAILURE
Definition WsfAdvancedBehaviorTreeNode.hpp:52
@ cHALTED
Definition WsfAdvancedBehaviorTreeNode.hpp:54
@ cDISABLED
Definition WsfAdvancedBehaviorTreeNode.hpp:55
@ cSUCCESS
Definition WsfAdvancedBehaviorTreeNode.hpp:51
@ cIDLE
Definition WsfAdvancedBehaviorTreeNode.hpp:53
@ cRUNNING
Definition WsfAdvancedBehaviorTreeNode.hpp:50
FailurePolicy
Failure policy for a Parallel composite node.
Definition WsfAdvancedBehaviorTreeNode.hpp:75
@ cFAIL_ON_ONE
Definition WsfAdvancedBehaviorTreeNode.hpp:76
@ cFAIL_ON_ALL
Definition WsfAdvancedBehaviorTreeNode.hpp:77
SuccessPolicy
Success policy for a Parallel composite node.
Definition WsfAdvancedBehaviorTreeNode.hpp:64
@ cSUCCEED_ON_ONE
Definition WsfAdvancedBehaviorTreeNode.hpp:65
@ cTHRESHOLD
Definition WsfAdvancedBehaviorTreeNode.hpp:67
@ cSUCCEED_ON_ALL
Definition WsfAdvancedBehaviorTreeNode.hpp:66
ResetPolicy
Reset policy for nodes with memory.
Definition WsfAdvancedBehaviorTreeNode.hpp:86
@ cON_SUCCESS_OR_FAILURE
Definition WsfAdvancedBehaviorTreeNode.hpp:87
@ cON_SUCCESS
Definition WsfAdvancedBehaviorTreeNode.hpp:88
@ cON_FAILURE
Definition WsfAdvancedBehaviorTreeNode.hpp:89
Copyrights Multiple, All Rights Reserved