14 #ifndef BEHAVIORTREECORE_TREENODE_H 15 #define BEHAVIORTREECORE_TREENODE_H 35 typedef std::chrono::high_resolution_clock::time_point
TimePoint;
36 typedef std::chrono::high_resolution_clock::duration
Duration;
60 TreeNode(
const std::string&
name,
const NodeParameters& parameters);
63 typedef std::shared_ptr<TreeNode>
Ptr;
69 virtual void halt() = 0;
81 const std::string&
name()
const;
105 uint16_t
UID()
const;
116 template <
typename T>
126 template <
typename T>
127 bool getParam(
const std::string& key, T& destination)
const;
169 template <
typename T>
inline 177 const std::string& str = it->second;
184 std::cerr <<
"you are calling getParam inside a constructor, but this is not allowed " 185 "when the parameter contains a blackboard.\n" 186 "You should call getParam inside your tick() method"<< std::endl;
187 std::logic_error(
"Calling getParam inside a constructor");
192 const std::string stripped_key(&str[2], str.size() - 3);
196 if( std::is_same<T,std::string>::value ==
false &&
197 (val->type() ==
typeid (std::string) ||
200 destination = convertFromString<T>(val->cast<std::string>());
203 destination = val->cast<T>();
206 return val !=
nullptr;
209 destination = convertFromString<T>(str.c_str());
213 catch (std::runtime_error& err)
215 std::cout <<
"Exception at getParam(" << key <<
"): " << err.what() << std::endl;
BT::optional< T > getParam(const std::string &key) const
std::condition_variable state_condition_variable_
StatusChangeSignal::Subscriber StatusChangeSubscriber
virtual NodeType type() const =0
std::function< void(CallableArgs...)> CallableFunction
const std::string & name() const
virtual void halt()=0
The method used to interrupt the execution of a RUNNING node.
std::chrono::high_resolution_clock::time_point TimePoint
const Blackboard::Ptr & blackboard() const
void setRegistrationName(const std::string ®istration_name)
registrationName() is set by the BehaviorTreeFactory
const NodeParameters & initializationParameters() const
StatusChangeSignal::CallableFunction StatusChangeCallback
static pthread_mutex_t mutex
std::shared_ptr< Blackboard > Ptr
StatusChangeSubscriber subscribeToStatusChange(StatusChangeCallback callback)
subscribeToStatusChange is used to attach a callback to a status change. When StatusChangeSubscriber ...
TreeNode(const std::string &name, const NodeParameters ¶meters)
TreeNode main constructor.
const nullopt_t nullopt((nullopt_t::init()))
std::shared_ptr< CallableFunction > Subscriber
std::unordered_map< std::string, std::string > NodeParameters
nonstd::string_view StringView
virtual ~TreeNode()=default
StatusChangeSignal state_change_signal_
const NodeParameters parameters_
NodeStatus status() const
std::shared_ptr< TreeNode > Ptr
static bool isBlackboardPattern(StringView str)
std::string registration_name_
virtual BT::NodeStatus executeTick()
The method that will be executed to invoke tick(); and setStatus();.
BT::NodeStatus waitValidStatus()
const std::string & registrationName() const
registrationName is the ID used by BehaviorTreeFactory to create an instance.
void setBlackboard(const Blackboard::Ptr &bb)
virtual BT::NodeStatus tick()=0
Method to be implemented by the user.
std::chrono::high_resolution_clock::duration Duration
void setStatus(NodeStatus new_status)