#include <tree_node.h>
Public Types | |
typedef std::shared_ptr< TreeNode > | Ptr |
using | StatusChangeCallback = StatusChangeSignal::CallableFunction |
using | StatusChangeSignal = Signal< TimePoint, const TreeNode &, NodeStatus, NodeStatus > |
using | StatusChangeSubscriber = StatusChangeSignal::Subscriber |
Public Member Functions | |
const Blackboard::Ptr & | blackboard () const |
virtual BT::NodeStatus | executeTick () |
The method that will be executed to invoke tick(); and setStatus();. More... | |
template<typename T > | |
BT::optional< T > | getParam (const std::string &key) const |
template<typename T > | |
bool | getParam (const std::string &key, T &destination) const |
virtual void | halt ()=0 |
The method used to interrupt the execution of a RUNNING node. More... | |
const NodeParameters & | initializationParameters () const |
bool | isHalted () const |
const std::string & | name () const |
const std::string & | registrationName () const |
registrationName is the ID used by BehaviorTreeFactory to create an instance. More... | |
void | setBlackboard (const Blackboard::Ptr &bb) |
void | setStatus (NodeStatus new_status) |
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 (const std::string &name, const NodeParameters ¶meters) | |
TreeNode main constructor. More... | |
virtual NodeType | type () const =0 |
uint16_t | UID () const |
BT::NodeStatus | waitValidStatus () |
virtual | ~TreeNode ()=default |
Static Public Member Functions | |
static bool | isBlackboardPattern (StringView str) |
Protected Member Functions | |
void | initializeOnce () |
void | setRegistrationName (const std::string ®istration_name) |
registrationName() is set by the BehaviorTreeFactory More... | |
virtual BT::NodeStatus | tick ()=0 |
Method to be implemented by the user. More... | |
Private Member Functions | |
virtual void | onInit () |
Private Attributes | |
Blackboard::Ptr | bb_ |
const std::string | name_ |
bool | not_initialized_ |
const NodeParameters | parameters_ |
std::string | registration_name_ |
StatusChangeSignal | state_change_signal_ |
std::condition_variable | state_condition_variable_ |
std::mutex | state_mutex_ |
NodeStatus | status_ |
const uint16_t | uid_ |
Friends | |
class | BehaviorTreeFactory |
Definition at line 39 of file tree_node.h.
typedef std::shared_ptr<TreeNode> BT::TreeNode::Ptr |
Definition at line 63 of file tree_node.h.
Definition at line 91 of file tree_node.h.
using BT::TreeNode::StatusChangeSignal = Signal<TimePoint, const TreeNode&, NodeStatus, NodeStatus> |
Definition at line 89 of file tree_node.h.
Definition at line 90 of file tree_node.h.
BT::TreeNode::TreeNode | ( | const std::string & | name, |
const NodeParameters & | parameters | ||
) |
TreeNode main constructor.
name | name of the instance, not the type of sensor. |
parameters | this might be empty. use getParam<T>(key) to parse the value. |
Note: a node that accepts a not empty set of NodeParameters must also implement the method:
static const NodeParameters& requiredNodeParameters();
Definition at line 25 of file tree_node.cpp.
|
virtualdefault |
const Blackboard::Ptr & BT::TreeNode::blackboard | ( | ) | const |
Definition at line 64 of file tree_node.cpp.
|
virtual |
The method that will be executed to invoke tick(); and setStatus();.
Reimplemented in BT::CoroActionNode, BT::AsyncActionNode, BT::SyncActionNode, BT::ActionNodeBase, and BT::DecoratorNode.
Definition at line 35 of file tree_node.cpp.
|
inline |
Get a parameter from the NodeParameters and convert it to type T.
Definition at line 117 of file tree_node.h.
|
inline |
Get a parameter from the passed NodeParameters and convert it to type T. Return false either if there is no parameter with this key or if conversion failed.
Definition at line 170 of file tree_node.h.
|
pure virtual |
The method used to interrupt the execution of a RUNNING node.
Implemented in BT::CoroActionNode, FollowPath, BT::SimpleActionNode, MoveBaseAction, BT::SyncActionNode, BT::SimpleConditionNode, MyAsyncAction, BT::ControlNode, BT::RepeatNode, BT::AsyncActionTest, BT::SequenceStarNode, BT::FallbackStarNode, BT::ParallelNode, BT::RetryNode, ActionTestNode, ActionTestNode, BT::ConditionNode, and BT::DecoratorNode.
const NodeParameters & BT::TreeNode::initializationParameters | ( | ) | const |
Parameters passed at construction time. Can never change after the creation of the TreeNode instance.
Definition at line 137 of file tree_node.cpp.
|
protected |
Definition at line 118 of file tree_node.cpp.
|
static |
Definition at line 127 of file tree_node.cpp.
bool BT::TreeNode::isHalted | ( | ) | const |
Definition at line 97 of file tree_node.cpp.
const std::string & BT::TreeNode::name | ( | ) | const |
Definition at line 92 of file tree_node.cpp.
|
inlineprivatevirtual |
This calback will be executed only ONCE after the constructor of the node, before the very first tick. Override if necessary.
Reimplemented in InitTestNode.
Definition at line 47 of file tree_node.h.
const std::string & BT::TreeNode::registrationName | ( | ) | const |
registrationName is the ID used by BehaviorTreeFactory to create an instance.
Definition at line 132 of file tree_node.cpp.
void BT::TreeNode::setBlackboard | ( | const Blackboard::Ptr & | bb | ) |
Definition at line 59 of file tree_node.cpp.
|
protected |
registrationName() is set by the BehaviorTreeFactory
Definition at line 113 of file tree_node.cpp.
void BT::TreeNode::setStatus | ( | NodeStatus | new_status | ) |
Definition at line 43 of file tree_node.cpp.
NodeStatus BT::TreeNode::status | ( | ) | const |
Definition at line 75 of file tree_node.cpp.
TreeNode::StatusChangeSubscriber BT::TreeNode::subscribeToStatusChange | ( | TreeNode::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.
callback. | Must have signature void funcname(NodeStatus prev_status, NodeStatus new_status) |
Definition at line 103 of file tree_node.cpp.
|
protectedpure virtual |
Method to be implemented by the user.
Implemented in FollowPath, ComputePathToPose, BT::SimpleActionNode, BackUpAndSpin, IsStuck, MoveBaseAction, BT::SimpleConditionNode, BT::SimpleDecoratorNode, BT::SequenceStarNode, DummyNodes::SaySomething, BT::ParallelNode, BT::RetryNode, BT::FallbackStarNode, BT::BlackboardPreconditionNode< T >, BT::RepeatNode, BT::FallbackNode, BT::SequenceNode, DummyNodes::ApproachObject, BT::AsyncActionTest, InitTestNode, BT::SetBlackboard, BT::TimeoutNode, BT::ForceFailureDecorator, BT::ForceSuccessDecorator, BT::InverterNode, BT::AlwaysFailure, BT::AlwaysSuccess, MyAsyncAction, ActionTestNode, ActionTestNode, BT::ConditionTestNode, BT::DecoratorSubtreeNode, and BT::SyncActionTest.
|
pure virtual |
Implemented in BT::ControlNode, BT::ActionNodeBase, BT::ConditionNode, BT::DecoratorNode, and BT::DecoratorSubtreeNode.
uint16_t BT::TreeNode::UID | ( | ) | const |
Definition at line 108 of file tree_node.cpp.
NodeStatus BT::TreeNode::waitValidStatus | ( | ) |
Blocking function that will sleep until the setStatus() is called with either RUNNING, FAILURE or SUCCESS.
Definition at line 81 of file tree_node.cpp.
|
friend |
Definition at line 138 of file tree_node.h.
|
private |
Definition at line 162 of file tree_node.h.
|
private |
Definition at line 146 of file tree_node.h.
|
private |
Definition at line 144 of file tree_node.h.
|
private |
Definition at line 160 of file tree_node.h.
|
private |
Definition at line 158 of file tree_node.h.
|
private |
Definition at line 154 of file tree_node.h.
|
private |
Definition at line 150 of file tree_node.h.
|
mutableprivate |
Definition at line 152 of file tree_node.h.
|
private |
Definition at line 148 of file tree_node.h.
|
private |
Definition at line 156 of file tree_node.h.