tree_node.h
Go to the documentation of this file.
1 /* Copyright (C) 2015-2018 Michele Colledanchise - All Rights Reserved
2 * Copyright (C) 2018-2023 Davide Faconti - All Rights Reserved
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
6 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
11 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 */
13 
14 #pragma once
15 
16 #include <exception>
17 #include <map>
18 #include <utility>
19 
26 
27 #ifdef _MSC_VER
28 #pragma warning(disable : 4127)
29 #endif
30 
31 namespace BT
32 {
33 
36 {
38  std::string registration_ID;
41 };
42 
43 using PortsRemapping = std::unordered_map<std::string, std::string>;
44 using NonPortAttributes = std::unordered_map<std::string, std::string>;
45 
46 enum class PreCond
47 {
48  // order of the enums also tell us the execution order
49  FAILURE_IF = 0,
50  SUCCESS_IF,
51  SKIP_IF,
52  WHILE_TRUE,
53  COUNT_
54 };
55 
56 static const std::array<std::string, 4> PreCondNames = { //
57  "_failureIf", "_successIf", "_skipIf", "_while"
58 };
59 
60 enum class PostCond
61 {
62  // order of the enums also tell us the execution order
63  ON_HALTED = 0,
64  ON_FAILURE,
65  ON_SUCCESS,
66  ALWAYS,
67  COUNT_
68 };
69 
70 static const std::array<std::string, 4> PostCondNames = { //
71  "_onHalted", "_onFailure", "_onSuccess", "_post"
72 };
73 
74 template <>
75 [[nodiscard]] std::string toStr<BT::PostCond>(const BT::PostCond& cond);
76 
77 template <>
78 [[nodiscard]] std::string toStr<BT::PreCond>(const BT::PreCond& cond);
79 
80 using ScriptingEnumsRegistry = std::unordered_map<std::string, int>;
81 
82 struct NodeConfig
83 {
85  {}
86 
87  // Pointer to the blackboard used by this node
89  // List of enums available for scripting
90  std::shared_ptr<ScriptingEnumsRegistry> enums;
91  // input ports
93  // output ports
95 
96  // Any other attributes found in the xml that are not parsed as ports
97  // or built-in identifier (e.g. anything with a leading '_')
99 
100  const TreeNodeManifest* manifest = nullptr;
101 
102  // Numberic unique identifier
103  uint16_t uid = 0;
104  // Unique human-readable name, that encapsulate the subtree
105  // hierarchy, for instance, given 2 nested trees, it should be:
106  //
107  // main_tree/nested_tree/my_action
108  std::string path;
109 
110  std::map<PreCond, std::string> pre_conditions;
111  std::map<PostCond, std::string> post_conditions;
112 };
113 
114 // back compatibility
116 
117 template <typename T>
118 inline constexpr bool hasNodeNameCtor()
119 {
121 }
122 
123 template <typename T, typename... ExtraArgs>
124 inline constexpr bool hasNodeFullCtor()
125 {
126  return std::is_constructible<T, const std::string&, const NodeConfig&,
127  ExtraArgs...>::value;
128 }
129 
131 class TreeNode
132 {
133 public:
134  typedef std::shared_ptr<TreeNode> Ptr;
135 
146  TreeNode(std::string name, NodeConfig config);
147 
148  TreeNode(const TreeNode& other) = delete;
149  TreeNode& operator=(const TreeNode& other) = delete;
150 
151  TreeNode(TreeNode&& other) noexcept;
152  TreeNode& operator=(TreeNode&& other) noexcept;
153 
154  virtual ~TreeNode();
155 
157  virtual BT::NodeStatus executeTick();
158 
159  void haltNode();
160 
161  [[nodiscard]] bool isHalted() const;
162 
163  [[nodiscard]] NodeStatus status() const;
164 
166  [[nodiscard]] const std::string& name() const;
167 
170  [[nodiscard]] BT::NodeStatus waitValidStatus();
171 
172  virtual NodeType type() const = 0;
173 
177 
178  using PreTickCallback = std::function<NodeStatus(TreeNode&)>;
179  using PostTickCallback = std::function<NodeStatus(TreeNode&, NodeStatus)>;
180  using TickMonitorCallback =
181  std::function<void(TreeNode&, NodeStatus, std::chrono::microseconds)>;
182 
192  [[nodiscard]] StatusChangeSubscriber
194 
205 
215 
225 
228  [[nodiscard]] uint16_t UID() const;
229 
232  [[nodiscard]] const std::string& fullPath() const;
233 
235  [[nodiscard]] const std::string& registrationName() const;
236 
239  [[nodiscard]] const NodeConfig& config() const;
240 
249  template <typename T>
250  Result getInput(const std::string& key, T& destination) const;
251 
260  template <typename T>
261  [[nodiscard]] Expected<Timestamp> getInputStamped(const std::string& key,
262  T& destination) const;
263 
269  template <typename T>
270  [[nodiscard]] Expected<T> getInput(const std::string& key) const
271  {
272  T out{};
273  auto res = getInput(key, out);
274  return (res) ? Expected<T>(out) : nonstd::make_unexpected(res.error());
275  }
276 
282  template <typename T>
283  [[nodiscard]] Expected<StampedValue<T>> getInputStamped(const std::string& key) const
284  {
285  StampedValue<T> out;
286  if(auto res = getInputStamped(key, out.value))
287  {
288  out.stamp = *res;
289  return out;
290  }
291  else
292  {
293  return nonstd::make_unexpected(res.error());
294  }
295  }
296 
303  template <typename T>
304  Result setOutput(const std::string& key, const T& value);
305 
336  [[nodiscard]] AnyPtrLocked getLockedPortContent(const std::string& key);
337 
338  // function provided mostly for debugging purpose to see the raw value
339  // in the port (no remapping and no conversion to a type)
340  [[nodiscard]] StringView getRawPortValue(const std::string& key) const;
341 
343  [[nodiscard]] static bool isBlackboardPointer(StringView str,
344  StringView* stripped_pointer = nullptr);
345 
346  [[nodiscard]] static StringView stripBlackboardPointer(StringView str);
347 
348  [[nodiscard]] static Expected<StringView> getRemappedKey(StringView port_name,
349  StringView remapped_port);
350 
352  void emitWakeUpSignal();
353 
354  [[nodiscard]] bool requiresWakeUp() const;
355 
359  template <class DerivedT, typename... ExtraArgs>
360  static std::unique_ptr<TreeNode> Instantiate(const std::string& name,
361  const NodeConfig& config,
362  ExtraArgs... args)
363  {
364  static_assert(hasNodeFullCtor<DerivedT, ExtraArgs...>() ||
365  hasNodeNameCtor<DerivedT>());
366 
367  if constexpr(hasNodeFullCtor<DerivedT, ExtraArgs...>())
368  {
369  return std::make_unique<DerivedT>(name, config, args...);
370  }
371  else if constexpr(hasNodeNameCtor<DerivedT>())
372  {
373  auto node_ptr = new DerivedT(name, args...);
374  node_ptr->config() = config;
375  return std::unique_ptr<DerivedT>(node_ptr);
376  }
377  }
378 
379 protected:
380  friend class BehaviorTreeFactory;
381  friend class DecoratorNode;
382  friend class ControlNode;
383  friend class Tree;
384 
385  [[nodiscard]] NodeConfig& config();
386 
388  virtual BT::NodeStatus tick() = 0;
389 
391  void resetStatus();
392 
393  // Only BehaviorTreeFactory should call this
394  void setRegistrationID(StringView ID);
395 
396  void setWakeUpInstance(std::shared_ptr<WakeUpSignal> instance);
397 
398  void modifyPortsRemapping(const PortsRemapping& new_remapping);
399 
405  void setStatus(NodeStatus new_status);
406 
407  using PreScripts = std::array<ScriptFunction, size_t(PreCond::COUNT_)>;
408  using PostScripts = std::array<ScriptFunction, size_t(PostCond::COUNT_)>;
409 
412 
413  template <typename T>
414  T parseString(const std::string& str) const;
415 
416 private:
417  struct PImpl;
418  std::unique_ptr<PImpl> _p;
419 
422 
425  virtual void halt() = 0;
426 };
427 
428 //-------------------------------------------------------
429 
430 template <typename T>
431 T TreeNode::parseString(const std::string& str) const
432 {
433  if constexpr(std::is_enum_v<T> && !std::is_same_v<T, NodeStatus>)
434  {
435  auto it = config().enums->find(str);
436  // conversion available
437  if(it != config().enums->end())
438  {
439  return static_cast<T>(it->second);
440  }
441  else
442  {
443  // hopefully str contains a number that can be parsed. May throw
444  return static_cast<T>(convertFromString<int>(str));
445  }
446  }
447  return convertFromString<T>(str);
448 }
449 
450 template <typename T>
451 inline Expected<Timestamp> TreeNode::getInputStamped(const std::string& key,
452  T& destination) const
453 {
454  std::string port_value_str;
455 
456  auto input_port_it = config().input_ports.find(key);
457  if(input_port_it != config().input_ports.end())
458  {
459  port_value_str = input_port_it->second;
460  }
461  else if(!config().manifest)
462  {
463  return nonstd::make_unexpected(StrCat("getInput() of node '", fullPath(),
464  "' failed because the manifest is "
465  "nullptr (WTF?) and the key: [",
466  key, "] is missing"));
467  }
468  else
469  {
470  // maybe it is declared with a default value in the manifest
471  auto port_manifest_it = config().manifest->ports.find(key);
472  if(port_manifest_it == config().manifest->ports.end())
473  {
474  return nonstd::make_unexpected(StrCat("getInput() of node '", fullPath(),
475  "' failed because the manifest doesn't "
476  "contain the key: [",
477  key, "]"));
478  }
479  const auto& port_info = port_manifest_it->second;
480  // there is a default value
481  if(port_info.defaultValue().empty())
482  {
483  return nonstd::make_unexpected(StrCat("getInput() of node '", fullPath(),
484  "' failed because nor the manifest or the "
485  "XML contain the key: [",
486  key, "]"));
487  }
488  if(port_info.defaultValue().isString())
489  {
490  port_value_str = port_info.defaultValue().cast<std::string>();
491  }
492  else
493  {
494  destination = port_info.defaultValue().cast<T>();
495  return Timestamp{};
496  }
497  }
498 
499  auto blackboard_ptr = getRemappedKey(key, port_value_str);
500  try
501  {
502  // pure string, not a blackboard key
503  if(!blackboard_ptr)
504  {
505  try
506  {
507  destination = parseString<T>(port_value_str);
508  }
509  catch(std::exception& ex)
510  {
511  return nonstd::make_unexpected(StrCat("getInput(): ", ex.what()));
512  }
513  return Timestamp{};
514  }
515  const auto& blackboard_key = blackboard_ptr.value();
516 
517  if(!config().blackboard)
518  {
519  return nonstd::make_unexpected("getInput(): trying to access "
520  "an invalid Blackboard");
521  }
522 
523  if(auto entry = config().blackboard->getEntry(std::string(blackboard_key)))
524  {
525  std::unique_lock lk(entry->entry_mutex);
526  auto& any_value = entry->value;
527 
528  // support getInput<Any>()
529  if constexpr(std::is_same_v<T, Any>)
530  {
531  destination = any_value;
532  return Timestamp{ entry->sequence_id, entry->stamp };
533  }
534 
535  if(!entry->value.empty())
536  {
537  if(!std::is_same_v<T, std::string> && any_value.isString())
538  {
539  destination = parseString<T>(any_value.cast<std::string>());
540  }
541  else
542  {
543  destination = any_value.cast<T>();
544  }
545  return Timestamp{ entry->sequence_id, entry->stamp };
546  }
547  }
548 
549  return nonstd::make_unexpected(StrCat("getInput() failed because it was unable to "
550  "find the key [",
551  key, "] remapped to [", blackboard_key, "]"));
552  }
553  catch(std::exception& err)
554  {
555  return nonstd::make_unexpected(err.what());
556  }
557 }
558 
559 template <typename T>
560 inline Result TreeNode::getInput(const std::string& key, T& destination) const
561 {
562  auto res = getInputStamped(key, destination);
563  if(!res)
564  {
565  return nonstd::make_unexpected(res.error());
566  }
567  return {};
568 }
569 
570 template <typename T>
571 inline Result TreeNode::setOutput(const std::string& key, const T& value)
572 {
573  if(!config().blackboard)
574  {
575  return nonstd::make_unexpected("setOutput() failed: trying to access a "
576  "Blackboard(BB) entry, but BB is invalid");
577  }
578 
579  auto remap_it = config().output_ports.find(key);
580  if(remap_it == config().output_ports.end())
581  {
582  return nonstd::make_unexpected(StrCat("setOutput() failed: "
583  "NodeConfig::output_ports "
584  "does not contain the key: [",
585  key, "]"));
586  }
587  StringView remapped_key = remap_it->second;
588  if(remapped_key == "{=}" || remapped_key == "=")
589  {
590  config().blackboard->set(static_cast<std::string>(key), value);
591  return {};
592  }
593 
594  if(!isBlackboardPointer(remapped_key))
595  {
596  return nonstd::make_unexpected("setOutput requires a blackboard pointer. Use {}");
597  }
598 
599  if constexpr(std::is_same_v<BT::Any, T>)
600  {
601  auto port_type = config().manifest->ports.at(key).type();
602  if(port_type != typeid(BT::Any) && port_type != typeid(BT::AnyTypeAllowed))
603  {
604  throw LogicError("setOutput<Any> is not allowed, unless the port "
605  "was declared using OutputPort<Any>");
606  }
607  }
608 
609  remapped_key = stripBlackboardPointer(remapped_key);
610  config().blackboard->set(static_cast<std::string>(remapped_key), value);
611 
612  return {};
613 }
614 
615 // Utility function to fill the list of ports using T::providedPorts();
616 template <typename T>
617 inline void assignDefaultRemapping(NodeConfig& config)
618 {
619  for(const auto& it : getProvidedPorts<T>())
620  {
621  const auto& port_name = it.first;
622  const auto direction = it.second.direction();
623  if(direction != PortDirection::OUTPUT)
624  {
625  // PortDirection::{INPUT,INOUT}
626  config.input_ports[port_name] = "{=}";
627  }
628  if(direction != PortDirection::INPUT)
629  {
630  // PortDirection::{OUTPUT,INOUT}
631  config.output_ports[port_name] = "{=}";
632  }
633  }
634 }
635 
636 } // namespace BT
BT::TreeNode::getInput
Result getInput(const std::string &key, T &destination) const
Definition: tree_node.h:560
BT
Definition: ex01_wrap_legacy.cpp:29
BT::PostCond::ON_SUCCESS
@ ON_SUCCESS
BT::Signal< TimePoint, const TreeNode &, NodeStatus, NodeStatus >::Subscriber
std::shared_ptr< CallableFunction > Subscriber
Definition: signal.h:19
BT::TreeNodeManifest::ports
PortsList ports
Definition: tree_node.h:39
BT::TreeNode::UID
uint16_t UID() const
Definition: tree_node.cpp:336
BT::NodeType
NodeType
Enumerates the possible types of nodes.
Definition: basic_types.h:20
BT::TreeNode::requiresWakeUp
bool requiresWakeUp() const
Definition: tree_node.cpp:434
BT::Any
Definition: safe_any.hpp:36
BT::StampedValue::stamp
Timestamp stamp
Definition: blackboard.h:25
BT::PreCond
PreCond
Definition: tree_node.h:46
BT::PreCond::FAILURE_IF
@ FAILURE_IF
BT::NodeConfig::pre_conditions
std::map< PreCond, std::string > pre_conditions
Definition: tree_node.h:110
BT::PreCond::SUCCESS_IF
@ SUCCESS_IF
BT::TreeNode::config
const NodeConfig & config() const
Definition: tree_node.cpp:351
BT::TreeNode::emitWakeUpSignal
void emitWakeUpSignal()
Notify that the tree should be ticked again()
Definition: tree_node.cpp:426
BT::StampedValue
Definition: blackboard.h:22
BT::TreeNode::StatusChangeSubscriber
StatusChangeSignal::Subscriber StatusChangeSubscriber
Definition: tree_node.h:175
BT::PostCond::ON_FAILURE
@ ON_FAILURE
BT::TreeNode::TickMonitorCallback
std::function< void(TreeNode &, NodeStatus, std::chrono::microseconds)> TickMonitorCallback
Definition: tree_node.h:181
BT::hasNodeFullCtor
constexpr bool hasNodeFullCtor()
Definition: tree_node.h:124
basic_types.h
BT::Expected
nonstd::expected< T, std::string > Expected
Definition: basic_types.h:85
BT::TreeNode::executeTick
virtual BT::NodeStatus executeTick()
The method that should be used to invoke tick() and setStatus();.
Definition: tree_node.cpp:71
BT::StringView
std::string_view StringView
Definition: basic_types.h:59
BT::NodeConfig::path
std::string path
Definition: tree_node.h:108
BT::NodeConfig::input_ports
PortsRemapping input_ports
Definition: tree_node.h:92
BT::ScriptFunction
std::function< Any(Ast::Environment &env)> ScriptFunction
Definition: script_parser.hpp:43
BT::PreCond::COUNT_
@ COUNT_
BT::TreeNode::setPreTickFunction
void setPreTickFunction(PreTickCallback callback)
Definition: tree_node.cpp:318
BT::TreeNode
Abstract base class for Behavior Tree Nodes.
Definition: tree_node.h:131
strcat.hpp
BT::Tree
Struct used to store a tree. If this object goes out of scope, the tree is destroyed.
Definition: bt_factory.h:91
BT::TreeNode::Ptr
std::shared_ptr< TreeNode > Ptr
Definition: tree_node.h:134
BT::TreeNodeManifest::type
NodeType type
Definition: tree_node.h:37
BT::DecoratorNode
Definition: decorator_node.h:8
manifest
string manifest
BT::Signal< TimePoint, const TreeNode &, NodeStatus, NodeStatus >::CallableFunction
std::function< void(CallableArgs...)> CallableFunction
Definition: signal.h:18
BT::LogicError
Definition: exceptions.h:45
BT::TreeNode::PreTickCallback
std::function< NodeStatus(TreeNode &)> PreTickCallback
Definition: tree_node.h:178
magic_enum::detail::value
constexpr E value(std::size_t i) noexcept
Definition: magic_enum.hpp:664
BT::PortDirection::OUTPUT
@ OUTPUT
detail::void
j template void())
Definition: json.hpp:4893
BT::NonPortAttributes
std::unordered_map< std::string, std::string > NonPortAttributes
Definition: tree_node.h:44
BT::TreeNode::registrationName
const std::string & registrationName() const
registrationName is the ID used by BehaviorTreeFactory to create an instance.
Definition: tree_node.cpp:346
BT::TreeNode::PostScripts
std::array< ScriptFunction, size_t(PostCond::COUNT_)> PostScripts
Definition: tree_node.h:408
BT::StampedValue::value
T value
Definition: blackboard.h:24
lexy::callback
constexpr auto callback(Fns &&... fns)
Creates a callback.
Definition: adapter.hpp:48
BT::Blackboard::Ptr
std::shared_ptr< Blackboard > Ptr
Definition: blackboard.h:35
BT::NodeConfig::blackboard
Blackboard::Ptr blackboard
Definition: tree_node.h:88
BT::PortsList
std::unordered_map< std::string, PortInfo > PortsList
Definition: basic_types.h:587
BT::TreeNode::status
NodeStatus status() const
Definition: tree_node.cpp:285
BT::TreeNode::setPostTickFunction
void setPostTickFunction(PostTickCallback callback)
Definition: tree_node.cpp:324
BT::TreeNode::waitValidStatus
BT::NodeStatus waitValidStatus()
Definition: tree_node.cpp:291
BT::TreeNodeManifest::registration_ID
std::string registration_ID
Definition: tree_node.h:38
BT::TreeNode::setStatus
void setStatus(NodeStatus new_status)
setStatus changes the status of the node. it will throw if you try to change the status to IDLE,...
Definition: tree_node.cpp:160
BT::Timestamp
Definition: basic_types.h:335
BT::TreeNode::setTickMonitorCallback
void setTickMonitorCallback(TickMonitorCallback callback)
Definition: tree_node.cpp:330
BT::TreeNode::getRawPortValue
StringView getRawPortValue(const std::string &key) const
Definition: tree_node.cpp:361
BT::TreeNode::halt
virtual void halt()=0
BT::TreeNode::parseString
T parseString(const std::string &str) const
Definition: tree_node.h:431
BT::TreeNode::getInputStamped
Expected< StampedValue< T > > getInputStamped(const std::string &key) const
Definition: tree_node.h:283
BT::TreeNode::haltNode
void haltNode()
Definition: tree_node.cpp:148
BT::TreeNode::Instantiate
static std::unique_ptr< TreeNode > Instantiate(const std::string &name, const NodeConfig &config, ExtraArgs... args)
Definition: tree_node.h:360
BT::PostCond
PostCond
Definition: tree_node.h:60
BT::NodeConfig::uid
uint16_t uid
Definition: tree_node.h:103
BT::TreeNodeManifest
This information is used mostly by the XMLParser.
Definition: tree_node.h:35
BT::TreeNode::PImpl
Definition: tree_node.cpp:21
BT::PostCondNames
static const std::array< std::string, 4 > PostCondNames
Definition: tree_node.h:70
BT::TreeNode::type
virtual NodeType type() const =0
BT::ScriptingEnumsRegistry
std::unordered_map< std::string, int > ScriptingEnumsRegistry
Definition: tree_node.h:80
BT::TreeNode::postConditionsScripts
PostScripts & postConditionsScripts()
Definition: tree_node.cpp:188
signal.h
BT::PortDirection::INPUT
@ INPUT
BT::TreeNode::getLockedPortContent
AnyPtrLocked getLockedPortContent(const std::string &key)
getLockedPortContent should be used when:
Definition: tree_node.cpp:486
BT::LockedPtr
The LockedPtr class is used to share a pointer to an object and a mutex that protects the read/write ...
Definition: locked_reference.hpp:16
BT::TreeNode::setRegistrationID
void setRegistrationID(StringView ID)
Definition: tree_node.cpp:439
BT::BehaviorTreeFactory
The BehaviorTreeFactory is used to create instances of a TreeNode at run-time.
Definition: bt_factory.h:209
BT::TreeNode::checkPostConditions
void checkPostConditions(NodeStatus status)
Definition: tree_node.cpp:246
BT::KeyValueVector
std::vector< std::pair< std::string, std::string > > KeyValueVector
Definition: basic_types.h:66
BT::StrCat
std::string StrCat()
Definition: strcat.hpp:46
BT::TreeNode::setOutput
Result setOutput(const std::string &key, const T &value)
setOutput modifies the content of an Output port
Definition: tree_node.h:571
BT::NodeConfig::manifest
const TreeNodeManifest * manifest
Definition: tree_node.h:100
BT::TreeNode::getInput
Expected< T > getInput(const std::string &key) const
Definition: tree_node.h:270
BT::TreeNode::name
const std::string & name() const
Name of the instance, not the type.
Definition: tree_node.cpp:302
BT::TreeNode::tick
virtual BT::NodeStatus tick()=0
Method to be implemented by the user.
BT::TreeNode::modifyPortsRemapping
void modifyPortsRemapping(const PortsRemapping &new_remapping)
Definition: tree_node.cpp:449
BT::PreCond::WHILE_TRUE
@ WHILE_TRUE
BT::TreeNode::operator=
TreeNode & operator=(const TreeNode &other)=delete
BT::TreeNode::preConditionsScripts
PreScripts & preConditionsScripts()
Definition: tree_node.cpp:183
BT::PortsRemapping
std::unordered_map< std::string, std::string > PortsRemapping
Definition: tree_node.h:43
BT::TreeNode::getRemappedKey
static Expected< StringView > getRemappedKey(StringView port_name, StringView remapped_port)
Definition: tree_node.cpp:411
BT::TreeNode::setWakeUpInstance
void setWakeUpInstance(std::shared_ptr< WakeUpSignal > instance)
Definition: tree_node.cpp:444
BT::TreeNode::getInputStamped
Expected< Timestamp > getInputStamped(const std::string &key, T &destination) const
getInputStamped is similar to getInput(dey, destination), but it returne also the Timestamp object,...
Definition: tree_node.h:451
BT::AnyTypeAllowed
Definition: basic_types.h:87
BT::TreeNode::subscribeToStatusChange
StatusChangeSubscriber subscribeToStatusChange(StatusChangeCallback callback)
subscribeToStatusChange is used to attach a callback to a status change. When StatusChangeSubscriber ...
Definition: tree_node.cpp:313
BT::PreCond::SKIP_IF
@ SKIP_IF
BT::PostCond::COUNT_
@ COUNT_
BT::NodeConfig::NodeConfig
NodeConfig()
Definition: tree_node.h:84
BT::TreeNodeManifest::metadata
KeyValueVector metadata
Definition: tree_node.h:40
BT::assignDefaultRemapping
void assignDefaultRemapping(NodeConfig &config)
Definition: tree_node.h:617
BT::NodeConfig::post_conditions
std::map< PostCond, std::string > post_conditions
Definition: tree_node.h:111
BT::PostCond::ALWAYS
@ ALWAYS
BT::TreeNode::TreeNode
TreeNode(std::string name, NodeConfig config)
TreeNode main constructor.
Definition: tree_node.cpp:53
BT::TreeNode::_p
std::unique_ptr< PImpl > _p
Definition: tree_node.h:417
BT::TreeNode::resetStatus
void resetStatus()
Set the status to IDLE.
Definition: tree_node.cpp:268
lexy::_detail::is_constructible
constexpr auto is_constructible
Definition: object.hpp:18
BT::TreeNode::PreScripts
std::array< ScriptFunction, size_t(PreCond::COUNT_)> PreScripts
Definition: tree_node.h:407
BT::TreeNode::fullPath
const std::string & fullPath() const
Definition: tree_node.cpp:341
BT::hasNodeNameCtor
constexpr bool hasNodeNameCtor()
Definition: tree_node.h:118
wakeup_signal.hpp
BT::TreeNode::checkPreConditions
Expected< NodeStatus > checkPreConditions()
Definition: tree_node.cpp:193
BT::TreeNode::~TreeNode
virtual ~TreeNode()
Definition: tree_node.cpp:68
BT::TreeNode::PostTickCallback
std::function< NodeStatus(TreeNode &, NodeStatus)> PostTickCallback
Definition: tree_node.h:179
BT::NodeConfig::output_ports
PortsRemapping output_ports
Definition: tree_node.h:94
BT::PreCondNames
static const std::array< std::string, 4 > PreCondNames
Definition: tree_node.h:56
BT::TreeNode::isHalted
bool isHalted() const
Definition: tree_node.cpp:307
BT::Result
Expected< std::monostate > Result
Definition: basic_types.h:333
BT::PostCond::ON_HALTED
@ ON_HALTED
BT::NodeConfig
Definition: tree_node.h:82
BT::Signal< TimePoint, const TreeNode &, NodeStatus, NodeStatus >
BT::TreeNode::isBlackboardPointer
static bool isBlackboardPointer(StringView str, StringView *stripped_pointer=nullptr)
Check a string and return true if it matches the pattern: {...}.
Definition: tree_node.cpp:375
blackboard.h
BT::NodeConfig::enums
std::shared_ptr< ScriptingEnumsRegistry > enums
Definition: tree_node.h:90
BT::ControlNode
Definition: control_node.h:21
BT::TreeNode::StatusChangeCallback
StatusChangeSignal::CallableFunction StatusChangeCallback
Definition: tree_node.h:176
BT::NodeStatus
NodeStatus
Definition: basic_types.h:33
script_parser.hpp
BT::TreeNode::stripBlackboardPointer
static StringView stripBlackboardPointer(StringView str)
Definition: tree_node.cpp:401
BT::NodeConfig::other_attributes
NonPortAttributes other_attributes
Definition: tree_node.h:98


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Wed Apr 16 2025 02:20:57