The AsyncActionNode uses a different thread, where the action will be executed. More...
#include <action_node.h>
Public Member Functions | |
AsyncActionNode (const std::string &name, const NodeConfiguration &config) | |
virtual NodeStatus | executeTick () override final |
The method that should be used to invoke tick() and setStatus();. More... | |
virtual void | halt () override |
bool | isHaltRequested () const |
![]() | |
ActionNodeBase (const std::string &name, const NodeConfiguration &config) | |
virtual NodeType | type () const override final |
~ActionNodeBase () override=default | |
![]() | |
LeafNode (const std::string &name, const NodeConfiguration &config) | |
virtual | ~LeafNode () override=default |
![]() | |
const NodeConfiguration & | config () const |
void | emitStateChanged () |
template<typename T > | |
Optional< T > | getInput (const std::string &key) const |
template<typename T > | |
Result | getInput (const std::string &key, T &destination) const |
StringView | getRawPortValue (const std::string &key) const |
bool | isHalted () const |
const std::string & | name () const |
Name of the instance, not the type. More... | |
const std::string & | registrationName () const |
registrationName is the ID used by BehaviorTreeFactory to create an instance. More... | |
template<typename T > | |
Result | setOutput (const std::string &key, const T &value) |
void | setPostTickOverrideFunction (PostTickOverrideCallback callback) |
void | setPreTickOverrideFunction (PreTickOverrideCallback callback) |
NodeStatus | status () const |
StatusChangeSubscriber | subscribeToStatusChange (StatusChangeCallback callback) |
subscribeToStatusChange is used to attach a callback to a status change. When StatusChangeSubscriber goes out of scope (it is a shared_ptr) the callback is unsubscribed automatically. More... | |
TreeNode (std::string name, NodeConfiguration config) | |
TreeNode main constructor. More... | |
uint16_t | UID () const |
BT::NodeStatus | waitValidStatus () |
virtual | ~TreeNode ()=default |
Private Attributes | |
std::exception_ptr | exptr_ |
std::atomic_bool | halt_requested_ |
std::mutex | mutex_ |
std::future< void > | thread_handle_ |
The AsyncActionNode uses a different thread, where the action will be executed.
IMPORTANT: this action is quite hard to implement correctly. Please be sure that you know what you are doing.
For a complete example, look at AsyncActionTest in action_test_node.h in the folder test.
NOTE: when the thread is completed, i.e. the tick() returns its status, a TreeNode::emitStateChanged() will be called.
Definition at line 114 of file action_node.h.
|
inline |
Definition at line 117 of file action_node.h.
|
finaloverridevirtual |
The method that should be used to invoke tick() and setStatus();.
Reimplemented from BT::TreeNode.
Definition at line 160 of file action_node.cpp.
|
overridevirtual |
The method used to interrupt the execution of a RUNNING node. Only Async nodes that may return RUNNING should implement it.
Implements BT::TreeNode.
Reimplemented in MoveBaseAction, and BT::AsyncActionTest.
Definition at line 204 of file action_node.cpp.
|
inline |
Definition at line 121 of file action_node.h.
|
private |
Definition at line 132 of file action_node.h.
|
private |
Definition at line 133 of file action_node.h.
|
private |
Definition at line 135 of file action_node.h.
|
private |
Definition at line 134 of file action_node.h.