WSF
WsfAdvancedBehaviorTree Class Reference

#include <WsfAdvancedBehaviorTree.hpp>

Inheritance diagram for WsfAdvancedBehaviorTree:
Collaboration diagram for WsfAdvancedBehaviorTree:

Public Member Functions

 WsfAdvancedBehaviorTree (const WsfScenario &aScenario)
 WsfAdvancedBehaviorTree (const WsfAdvancedBehaviorTree &aSrc)
 ~WsfAdvancedBehaviorTree () override=default
WsfAdvancedBehaviorTreeoperator= (const WsfAdvancedBehaviorTree &aRhs)=delete
void AddBlackboard (const std::string &aName, std::shared_ptr< WsfAttributeContainer > aBlackboardPtr)
 Add a blackboard to the blackboard list.
WsfAdvancedBehaviorTreeClone () const override
 Clone this tree.
WsfAttributeContainerGetSharedBlackboard (const std::string &aName) const
 Get a blackboard with the specified name from the shared list.
std::vector< std::string > GetSharedBlackboardNames () const
 Get a list of all shared blackboard names.
WsfSimulationGetSimulation ()
 Return a pointer to the simulation.
bool Initialize (double aSimTime, WsfScriptProcessor *aParentPtr, WsfScriptContext *aParentContextPtr=nullptr)
 Initialize this tree.
const size_t NodeCount () const
 Return a count of all leaf nodes.
const unsigned int & GetTreeId () const
 Get the id of this tree.
const std::string & GetName () const
 Get the name of this tree.
WsfAdvancedBehaviorTreeActionNodeNodeEntry (size_t aIndex) const
 Returns an action node at an index.
WsfScriptProcessorGetParentProcessor () const
 Return a pointer to the parent processor of this tree.
bool ProcessInput (UtInput &aInput) override
 Process input from a script.
void RegisterActionNode (WsfAdvancedBehaviorTreeActionNode *aNodePtr)
 Register an action node in our list, for easier tracking and updating in the processor.
std::shared_ptr< WsfAdvancedBehaviorTreeCompositeNodeRootNode () const
 Return a shared pointer to the root node of this tree.
const bool SharedBlackboardExists (const std::string &aName) const
 Get if a blackboard with the specified name exists in the shared list.
void SetShouldOutputNextTick (const bool aValue)
 Set if the tree should output node values to the event pipe next tick.
bool Tick (double aSimTime)
 Tick(update) the tree.
WsfAdvancedBehaviorTreeNodeFindNode (const std::string &aNodeName) const
 Find and return a pointer to the node with a given name.
void FindLastExecuted (std::vector< WsfAdvancedBehaviorTreeNode * > &aLastExecuted) const
 Fill a given vector with pointers to nodes that executed last tick.
WsfPlatformGetOwningPlatform () const
 Return a pointer to the owning platform of this tree.
const char * GetScriptClassName () const override
 Return the script class name for this tree.
const WsfScriptContextGetScriptContext () const
 Returns a reference to the script context for this tree.
void SetParent (WsfScriptProcessor *aParentPtr)
 Set the parent processor.
void SetParentContext (WsfScriptContext *aParentContextPtr)
 Set the parent script context for this tree.
void SetRootNodeClass ()
 Cast the root node to the composite node class set in the tree.
void OutputTreeStructure (const double aSimTime)
 Output the structure of this tree to the event pipe.
void OutputTreeState (const double aSimTime)
 Output the state of this tree to the event pipe.
void SetSuccessPolicy (const BT::SuccessPolicy aPolicy)
 Set the success policy for this node.
void SetThreshold (const unsigned int aThreshold)
 Set the threshold(number) of children that must succeed for this node to succeed.
Public Member Functions inherited from WsfObject
 WsfObject ()
 This is the constructor for the WsfObject class.
 ~WsfObject () override
 This is the destructor for the WsfObject class.
const char * GetScriptClassName () const override
const std::string & GetType () const
WsfStringId GetTypeId () const
 Get the string ID of the 'type' of the object.
void SetType (WsfStringId aType)
const std::string & GetBaseType () const
WsfStringId GetBaseTypeId () const
const TypeListGetTypeList () const
bool IsA_TypeOf (WsfStringId aType) const
WsfObjectoperator= (const WsfObject &aRhs)
 Assignment operator.
template<typename T>
void Serialize (T &aBuff)
 For XIO (de)serialization.
const std::string & GetName () const
WsfStringId GetNameId () const
void SetName (WsfStringId aName)

Static Public Member Functions

static unsigned int GetUniqueTreeId ()
 Get a unique int id for this tree.
static void Reset ()
 Reset the unique int counter.

Protected Member Functions

UtScriptContext * GetScriptAccessibleContext () const override
 Return the context from the script.
bool RegisterExternVariable (const std::string &aVariableType, const std::string &aVariableName)
 Register an external variable.
 WsfObject (const WsfObject &aSrc)
 Copy constructor (for Clone()).

Additional Inherited Members

Public Types inherited from WsfObject
typedef std::vector< WsfStringIdTypeList
 The list of types returned by GetTypeList.

Constructor & Destructor Documentation

◆ WsfAdvancedBehaviorTree() [1/2]

WsfAdvancedBehaviorTree::WsfAdvancedBehaviorTree ( const WsfScenario & aScenario)

◆ WsfAdvancedBehaviorTree() [2/2]

◆ ~WsfAdvancedBehaviorTree()

WsfAdvancedBehaviorTree::~WsfAdvancedBehaviorTree ( )
overridedefault

Member Function Documentation

◆ AddBlackboard()

void WsfAdvancedBehaviorTree::AddBlackboard ( const std::string & aName,
std::shared_ptr< WsfAttributeContainer > aBlackboardPtr )

Add a blackboard to the blackboard list.

Parameters
aNamename to reference blackboard with.
aBlackboardPtrblackboard to add.

Referenced by operator=().

◆ Clone()

WsfAdvancedBehaviorTree * WsfAdvancedBehaviorTree::Clone ( ) const
overridevirtual

Clone this tree.

Implements WsfObject.

References WsfAdvancedBehaviorTree().

◆ FindLastExecuted()

void WsfAdvancedBehaviorTree::FindLastExecuted ( std::vector< WsfAdvancedBehaviorTreeNode * > & aLastExecuted) const

Fill a given vector with pointers to nodes that executed last tick.

Parameters
aLastExecutedvector to fill.

Referenced by UT_DEFINE_SCRIPT_METHOD().

◆ FindNode()

WsfAdvancedBehaviorTreeNode * WsfAdvancedBehaviorTree::FindNode ( const std::string & aNodeName) const

Find and return a pointer to the node with a given name.

Parameters
aNodeNamename of the node to find.

Referenced by UT_DEFINE_SCRIPT_METHOD(), and UT_DEFINE_SCRIPT_METHOD().

◆ GetName()

const std::string & WsfAdvancedBehaviorTree::GetName ( ) const
inline

Get the name of this tree.

◆ GetOwningPlatform()

WsfPlatform * WsfAdvancedBehaviorTree::GetOwningPlatform ( ) const

Return a pointer to the owning platform of this tree.

References WsfScriptContext::GetPLATFORM().

Referenced by WsfAdvancedBehaviorTreeNode::GetOwningPlatform().

◆ GetParentProcessor()

WsfScriptProcessor * WsfAdvancedBehaviorTree::GetParentProcessor ( ) const
inline

Return a pointer to the parent processor of this tree.

Referenced by WsfAdvancedBehaviorTreeNode::GetOwningProcessor().

◆ GetScriptAccessibleContext()

UtScriptContext * WsfAdvancedBehaviorTree::GetScriptAccessibleContext ( ) const
overrideprotected

Return the context from the script.

References WsfPlatform::GetContext().

◆ GetScriptClassName()

const char * WsfAdvancedBehaviorTree::GetScriptClassName ( ) const
override

Return the script class name for this tree.

◆ GetScriptContext()

const WsfScriptContext & WsfAdvancedBehaviorTree::GetScriptContext ( ) const
inline

Returns a reference to the script context for this tree.

Referenced by WsfAdvancedBehaviorTree().

◆ GetSharedBlackboard()

WsfAttributeContainer * WsfAdvancedBehaviorTree::GetSharedBlackboard ( const std::string & aName) const

Get a blackboard with the specified name from the shared list.

Parameters
aNamename of the blackboard to get

References SharedBlackboardExists().

Referenced by operator=(), and UT_DEFINE_SCRIPT_METHOD().

◆ GetSharedBlackboardNames()

std::vector< std::string > WsfAdvancedBehaviorTree::GetSharedBlackboardNames ( ) const

Get a list of all shared blackboard names.

Referenced by operator=().

◆ GetSimulation()

WsfSimulation * WsfAdvancedBehaviorTree::GetSimulation ( )

Return a pointer to the simulation.

References WsfSimulation::GetScriptContext(), and WsfScriptContext::GetSimulation().

Referenced by operator=(), OutputTreeState(), and OutputTreeStructure().

◆ GetTreeId()

const unsigned int & WsfAdvancedBehaviorTree::GetTreeId ( ) const
inline

Get the id of this tree.

◆ GetUniqueTreeId()

unsigned int WsfAdvancedBehaviorTree::GetUniqueTreeId ( )
inlinestatic

Get a unique int id for this tree.

Referenced by WsfAdvancedBehaviorTree(), and WsfAdvancedBehaviorTree().

◆ Initialize()

bool WsfAdvancedBehaviorTree::Initialize ( double aSimTime,
WsfScriptProcessor * aParentPtr,
WsfScriptContext * aParentContextPtr = nullptr )

Initialize this tree.

Parameters
aSimTimesim time at initialization.
aParentPtrpointer to the parent script processor.
aParentContextPtrpointer to the parent script context.

References OutputTreeStructure(), and WsfScriptContext::SetParent().

Referenced by operator=().

◆ NodeCount()

const size_t WsfAdvancedBehaviorTree::NodeCount ( ) const
inline

Return a count of all leaf nodes.

Referenced by UT_DEFINE_SCRIPT_METHOD().

◆ NodeEntry()

WsfAdvancedBehaviorTreeActionNode * WsfAdvancedBehaviorTree::NodeEntry ( size_t aIndex) const

Returns an action node at an index.

Parameters
aIndexindex of node to retrieve.

Referenced by UT_DEFINE_SCRIPT_METHOD().

◆ operator=()

◆ OutputTreeState()

void WsfAdvancedBehaviorTree::OutputTreeState ( const double aSimTime)

Output the state of this tree to the event pipe.

Parameters
aSimTimetime at output.

References WsfObserver::AdvancedBehaviorTreeState(), and GetSimulation().

◆ OutputTreeStructure()

void WsfAdvancedBehaviorTree::OutputTreeStructure ( const double aSimTime)

Output the structure of this tree to the event pipe.

Parameters
aSimTimetime at output.

References WsfObserver::AdvancedBehaviorTree(), and GetSimulation().

Referenced by Initialize().

◆ ProcessInput()

bool WsfAdvancedBehaviorTree::ProcessInput ( UtInput & aInput)
overridevirtual

Process input from a script.

Parameters
aInputinput to parse.

Reimplemented from WsfObject.

References WsfAdvancedBehaviorTreeNode::SetFilePath().

◆ RegisterActionNode()

void WsfAdvancedBehaviorTree::RegisterActionNode ( WsfAdvancedBehaviorTreeActionNode * aNodePtr)

Register an action node in our list, for easier tracking and updating in the processor.

Parameters
aNodePtrnode to register.

◆ RegisterExternVariable()

bool WsfAdvancedBehaviorTree::RegisterExternVariable ( const std::string & aVariableType,
const std::string & aVariableName )
protected

Register an external variable.

Parameters
aVariableTypevariable type to register.
aVariableNamename of the variable.

References RegisterExternVariable().

Referenced by RegisterExternVariable(), and WsfAdvancedBehaviorTree().

◆ Reset()

void WsfAdvancedBehaviorTree::Reset ( )
inlinestatic

Reset the unique int counter.

◆ RootNode()

std::shared_ptr< WsfAdvancedBehaviorTreeCompositeNode > WsfAdvancedBehaviorTree::RootNode ( ) const
inline

Return a shared pointer to the root node of this tree.

Referenced by WsfAdvancedBehaviorTreeNode::SetExecuteTooltip(), and WsfAdvancedBehaviorTreeNode::SetPreconditionTooltip().

◆ SetParent()

void WsfAdvancedBehaviorTree::SetParent ( WsfScriptProcessor * aParentPtr)
inline

Set the parent processor.

Parameters
aParentPtrparent to set.

◆ SetParentContext()

void WsfAdvancedBehaviorTree::SetParentContext ( WsfScriptContext * aParentContextPtr)
inline

Set the parent script context for this tree.

Parameters
aParentContextPtrparent context to set.

◆ SetRootNodeClass()

void WsfAdvancedBehaviorTree::SetRootNodeClass ( )

Cast the root node to the composite node class set in the tree.

References BT::cON_FAILURE, and BT::cON_SUCCESS.

Referenced by WsfAdvancedBehaviorTree().

◆ SetShouldOutputNextTick()

void WsfAdvancedBehaviorTree::SetShouldOutputNextTick ( const bool aValue)
inline

Set if the tree should output node values to the event pipe next tick.

Parameters
aValuevalue to set.

Referenced by WsfAdvancedBehaviorTreeNode::SetNodeStatus().

◆ SetSuccessPolicy()

void WsfAdvancedBehaviorTree::SetSuccessPolicy ( const BT::SuccessPolicy aPolicy)
inline

Set the success policy for this node.

Parameters
aPolicypolicy to use when evaluating for success

◆ SetThreshold()

void WsfAdvancedBehaviorTree::SetThreshold ( const unsigned int aThreshold)
inline

Set the threshold(number) of children that must succeed for this node to succeed.

Parameters
aThresholdthe threshold that must be hit for this node to succeed.

◆ SharedBlackboardExists()

const bool WsfAdvancedBehaviorTree::SharedBlackboardExists ( const std::string & aName) const

Get if a blackboard with the specified name exists in the shared list.

Parameters
aNamename of the blackboard to get

Referenced by GetSharedBlackboard().

◆ Tick()

bool WsfAdvancedBehaviorTree::Tick ( double aSimTime)

Tick(update) the tree.

Parameters
aSimTimesim time when this function is called.

The documentation for this class was generated from the following files:
Copyrights Multiple, All Rights Reserved