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 
45 enum class PreCond
46 {
47  // order of the enums also tell us the execution order
48  FAILURE_IF = 0,
49  SUCCESS_IF,
50  SKIP_IF,
51  WHILE_TRUE,
52  COUNT_
53 };
54 
55 enum class PostCond
56 {
57  // order of the enums also tell us the execution order
58  ON_HALTED = 0,
59  ON_FAILURE,
60  ON_SUCCESS,
61  ALWAYS,
62  COUNT_
63 };
64 
65 template <>
66 [[nodiscard]] std::string toStr<BT::PostCond>(const BT::PostCond& status);
67 
68 template <>
69 [[nodiscard]] std::string toStr<BT::PreCond>(const BT::PreCond& status);
70 
71 using ScriptingEnumsRegistry = std::unordered_map<std::string, int>;
72 
73 struct NodeConfig
74 {
76  {}
77 
78  // Pointer to the blackboard used by this node
80  // List of enums available for scripting
81  std::shared_ptr<ScriptingEnumsRegistry> enums;
82  // input ports
84  // output ports
86 
87  const TreeNodeManifest* manifest = nullptr;
88 
89  // Numberic unique identifier
90  uint16_t uid = 0;
91  // Unique human-readable name, that encapsulate the subtree
92  // hierarchy, for instance, given 2 nested trees, it should be:
93  //
94  // main_tree/nested_tree/my_action
95  std::string path;
96 
97  std::map<PreCond, std::string> pre_conditions;
98  std::map<PostCond, std::string> post_conditions;
99 };
100 
101 // back compatibility
103 
104 template <typename T>
105 inline constexpr bool hasNodeNameCtor()
106 {
108 }
109 
110 template <typename T, typename... ExtraArgs>
111 inline constexpr bool hasNodeFullCtor()
112 {
113  return std::is_constructible<T, const std::string&, const NodeConfig&,
114  ExtraArgs...>::value;
115 }
116 
118 class TreeNode
119 {
120 public:
121  typedef std::shared_ptr<TreeNode> Ptr;
122 
133  TreeNode(std::string name, NodeConfig config);
134 
135  TreeNode(const TreeNode& other) = delete;
136  TreeNode& operator=(const TreeNode& other) = delete;
137 
138  TreeNode(TreeNode&& other) noexcept;
139  TreeNode& operator=(TreeNode&& other) noexcept;
140 
141  virtual ~TreeNode();
142 
144  virtual BT::NodeStatus executeTick();
145 
146  void haltNode();
147 
148  [[nodiscard]] bool isHalted() const;
149 
150  [[nodiscard]] NodeStatus status() const;
151 
153  [[nodiscard]] const std::string& name() const;
154 
157  [[nodiscard]] BT::NodeStatus waitValidStatus();
158 
159  virtual NodeType type() const = 0;
160 
164 
165  using PreTickCallback = std::function<NodeStatus(TreeNode&)>;
166  using PostTickCallback = std::function<NodeStatus(TreeNode&, NodeStatus)>;
167  using TickMonitorCallback =
168  std::function<void(TreeNode&, NodeStatus, std::chrono::microseconds)>;
169 
179  [[nodiscard]] StatusChangeSubscriber
181 
192 
202 
212 
215  [[nodiscard]] uint16_t UID() const;
216 
219  [[nodiscard]] const std::string& fullPath() const;
220 
222  [[nodiscard]] const std::string& registrationName() const;
223 
226  [[nodiscard]] const NodeConfig& config() const;
227 
236  template <typename T>
237  Result getInput(const std::string& key, T& destination) const;
238 
247  template <typename T>
248  [[nodiscard]] Expected<Timestamp> getInputStamped(const std::string& key,
249  T& destination) const;
250 
256  template <typename T>
257  [[nodiscard]] Expected<T> getInput(const std::string& key) const
258  {
259  T out{};
260  auto res = getInput(key, out);
261  return (res) ? Expected<T>(out) : nonstd::make_unexpected(res.error());
262  }
263 
269  template <typename T>
270  [[nodiscard]] Expected<StampedValue<T>> getInputStamped(const std::string& key) const
271  {
272  StampedValue<T> out;
273  if(auto res = getInputStamped(key, out.value))
274  {
275  out.stamp = *res;
276  return out;
277  }
278  else
279  {
280  return nonstd::make_unexpected(res.error());
281  }
282  }
283 
290  template <typename T>
291  Result setOutput(const std::string& key, const T& value);
292 
323  [[nodiscard]] AnyPtrLocked getLockedPortContent(const std::string& key);
324 
325  // function provided mostly for debugging purpose to see the raw value
326  // in the port (no remapping and no conversion to a type)
327  [[nodiscard]] StringView getRawPortValue(const std::string& key) const;
328 
330  [[nodiscard]] static bool isBlackboardPointer(StringView str,
331  StringView* stripped_pointer = nullptr);
332 
333  [[nodiscard]] static StringView stripBlackboardPointer(StringView str);
334 
335  [[nodiscard]] static Expected<StringView> getRemappedKey(StringView port_name,
336  StringView remapped_port);
337 
339  void emitWakeUpSignal();
340 
341  [[nodiscard]] bool requiresWakeUp() const;
342 
346  template <class DerivedT, typename... ExtraArgs>
347  static std::unique_ptr<TreeNode> Instantiate(const std::string& name,
348  const NodeConfig& config,
349  ExtraArgs... args)
350  {
351  static_assert(hasNodeFullCtor<DerivedT, ExtraArgs...>() ||
352  hasNodeNameCtor<DerivedT>());
353 
354  if constexpr(hasNodeFullCtor<DerivedT, ExtraArgs...>())
355  {
356  return std::make_unique<DerivedT>(name, config, args...);
357  }
358  else if constexpr(hasNodeNameCtor<DerivedT>())
359  {
360  auto node_ptr = new DerivedT(name, args...);
361  node_ptr->config() = config;
362  return std::unique_ptr<DerivedT>(node_ptr);
363  }
364  }
365 
366 protected:
367  friend class BehaviorTreeFactory;
368  friend class DecoratorNode;
369  friend class ControlNode;
370  friend class Tree;
371 
372  [[nodiscard]] NodeConfig& config();
373 
375  virtual BT::NodeStatus tick() = 0;
376 
378  void resetStatus();
379 
380  // Only BehaviorTreeFactory should call this
381  void setRegistrationID(StringView ID);
382 
383  void setWakeUpInstance(std::shared_ptr<WakeUpSignal> instance);
384 
385  void modifyPortsRemapping(const PortsRemapping& new_remapping);
386 
392  void setStatus(NodeStatus new_status);
393 
394  using PreScripts = std::array<ScriptFunction, size_t(PreCond::COUNT_)>;
395  using PostScripts = std::array<ScriptFunction, size_t(PostCond::COUNT_)>;
396 
399 
400  template <typename T>
401  T parseString(const std::string& str) const;
402 
403 private:
404  struct PImpl;
405  std::unique_ptr<PImpl> _p;
406 
409 
412  virtual void halt() = 0;
413 };
414 
415 //-------------------------------------------------------
416 
417 template <typename T>
418 T TreeNode::parseString(const std::string& str) const
419 {
420  if constexpr(std::is_enum_v<T> && !std::is_same_v<T, NodeStatus>)
421  {
422  auto it = config().enums->find(str);
423  // conversion available
424  if(it != config().enums->end())
425  {
426  return static_cast<T>(it->second);
427  }
428  else
429  {
430  // hopefully str contains a number that can be parsed. May throw
431  return static_cast<T>(convertFromString<int>(str));
432  }
433  }
434  return convertFromString<T>(str);
435 }
436 
437 template <typename T>
438 inline Expected<Timestamp> TreeNode::getInputStamped(const std::string& key,
439  T& destination) const
440 {
441  std::string port_value_str;
442 
443  auto input_port_it = config().input_ports.find(key);
444  if(input_port_it != config().input_ports.end())
445  {
446  port_value_str = input_port_it->second;
447  }
448  else if(!config().manifest)
449  {
450  return nonstd::make_unexpected(StrCat("getInput() of node '", fullPath(),
451  "' failed because the manifest is "
452  "nullptr (WTF?) and the key: [",
453  key, "] is missing"));
454  }
455  else
456  {
457  // maybe it is declared with a default value in the manifest
458  auto port_manifest_it = config().manifest->ports.find(key);
459  if(port_manifest_it == config().manifest->ports.end())
460  {
461  return nonstd::make_unexpected(StrCat("getInput() of node '", fullPath(),
462  "' failed because the manifest doesn't "
463  "contain the key: [",
464  key, "]"));
465  }
466  const auto& port_info = port_manifest_it->second;
467  // there is a default value
468  if(port_info.defaultValue().empty())
469  {
470  return nonstd::make_unexpected(StrCat("getInput() of node '", fullPath(),
471  "' failed because nor the manifest or the "
472  "XML contain the key: [",
473  key, "]"));
474  }
475  if(port_info.defaultValue().isString())
476  {
477  port_value_str = port_info.defaultValue().cast<std::string>();
478  }
479  else
480  {
481  destination = port_info.defaultValue().cast<T>();
482  return Timestamp{};
483  }
484  }
485 
486  auto blackboard_ptr = getRemappedKey(key, port_value_str);
487  try
488  {
489  // pure string, not a blackboard key
490  if(!blackboard_ptr)
491  {
492  try
493  {
494  destination = parseString<T>(port_value_str);
495  }
496  catch(std::exception& ex)
497  {
498  return nonstd::make_unexpected(StrCat("getInput(): ", ex.what()));
499  }
500  return Timestamp{};
501  }
502  const auto& blackboard_key = blackboard_ptr.value();
503 
504  if(!config().blackboard)
505  {
506  return nonstd::make_unexpected("getInput(): trying to access "
507  "an invalid Blackboard");
508  }
509 
510  if(auto entry = config().blackboard->getEntry(std::string(blackboard_key)))
511  {
512  std::unique_lock lk(entry->entry_mutex);
513  auto& any_value = entry->value;
514 
515  // support getInput<Any>()
516  if constexpr(std::is_same_v<T, Any>)
517  {
518  destination = any_value;
519  return Timestamp{ entry->sequence_id, entry->stamp };
520  }
521 
522  if(!entry->value.empty())
523  {
524  if(!std::is_same_v<T, std::string> && any_value.isString())
525  {
526  destination = parseString<T>(any_value.cast<std::string>());
527  }
528  else
529  {
530  destination = any_value.cast<T>();
531  }
532  return Timestamp{ entry->sequence_id, entry->stamp };
533  }
534  }
535 
536  return nonstd::make_unexpected(StrCat("getInput() failed because it was unable to "
537  "find the key [",
538  key, "] remapped to [", blackboard_key, "]"));
539  }
540  catch(std::exception& err)
541  {
542  return nonstd::make_unexpected(err.what());
543  }
544 }
545 
546 template <typename T>
547 inline Result TreeNode::getInput(const std::string& key, T& destination) const
548 {
549  auto res = getInputStamped(key, destination);
550  if(!res)
551  {
552  return nonstd::make_unexpected(res.error());
553  }
554  return {};
555 }
556 
557 template <typename T>
558 inline Result TreeNode::setOutput(const std::string& key, const T& value)
559 {
560  if(!config().blackboard)
561  {
562  return nonstd::make_unexpected("setOutput() failed: trying to access a "
563  "Blackboard(BB) entry, but BB is invalid");
564  }
565 
566  auto remap_it = config().output_ports.find(key);
567  if(remap_it == config().output_ports.end())
568  {
569  return nonstd::make_unexpected(StrCat("setOutput() failed: "
570  "NodeConfig::output_ports "
571  "does not contain the key: [",
572  key, "]"));
573  }
574  StringView remapped_key = remap_it->second;
575  if(remapped_key == "{=}" || remapped_key == "=")
576  {
577  config().blackboard->set(static_cast<std::string>(key), value);
578  return {};
579  }
580 
581  if(!isBlackboardPointer(remapped_key))
582  {
583  return nonstd::make_unexpected("setOutput requires a blackboard pointer. Use {}");
584  }
585 
586  if constexpr(std::is_same_v<BT::Any, T>)
587  {
588  if(config().manifest->ports.at(key).type() != typeid(BT::Any))
589  {
590  throw LogicError("setOutput<Any> is not allowed, unless the port "
591  "was declared using OutputPort<Any>");
592  }
593  }
594 
595  remapped_key = stripBlackboardPointer(remapped_key);
596  config().blackboard->set(static_cast<std::string>(remapped_key), value);
597 
598  return {};
599 }
600 
601 // Utility function to fill the list of ports using T::providedPorts();
602 template <typename T>
603 inline void assignDefaultRemapping(NodeConfig& config)
604 {
605  for(const auto& it : getProvidedPorts<T>())
606  {
607  const auto& port_name = it.first;
608  const auto direction = it.second.direction();
609  if(direction != PortDirection::OUTPUT)
610  {
611  // PortDirection::{INPUT,INOUT}
612  config.input_ports[port_name] = "{=}";
613  }
614  if(direction != PortDirection::INPUT)
615  {
616  // PortDirection::{OUTPUT,INOUT}
617  config.output_ports[port_name] = "{=}";
618  }
619  }
620 }
621 
622 } // namespace BT
BT::TreeNode::getInput
Result getInput(const std::string &key, T &destination) const
Definition: tree_node.h:547
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:45
BT::PreCond::FAILURE_IF
@ FAILURE_IF
BT::NodeConfig::pre_conditions
std::map< PreCond, std::string > pre_conditions
Definition: tree_node.h:97
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:162
BT::PostCond::ON_FAILURE
@ ON_FAILURE
BT::TreeNode::TickMonitorCallback
std::function< void(TreeNode &, NodeStatus, std::chrono::microseconds)> TickMonitorCallback
Definition: tree_node.h:168
BT::hasNodeFullCtor
constexpr bool hasNodeFullCtor()
Definition: tree_node.h:111
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:95
BT::NodeConfig::input_ports
PortsRemapping input_ports
Definition: tree_node.h:83
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:118
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:121
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:165
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::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:395
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:79
BT::PortsList
std::unordered_map< std::string, PortInfo > PortsList
Definition: basic_types.h:585
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:418
BT::TreeNode::getInputStamped
Expected< StampedValue< T > > getInputStamped(const std::string &key) const
Definition: tree_node.h:270
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:347
BT::PostCond
PostCond
Definition: tree_node.h:55
BT::NodeConfig::uid
uint16_t uid
Definition: tree_node.h:90
BT::TreeNodeManifest
This information is used mostly by the XMLParser.
Definition: tree_node.h:35
BT::TreeNode::PImpl
Definition: tree_node.cpp:21
BT::TreeNode::type
virtual NodeType type() const =0
BT::ScriptingEnumsRegistry
std::unordered_map< std::string, int > ScriptingEnumsRegistry
Definition: tree_node.h:71
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:502
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:558
BT::NodeConfig::manifest
const TreeNodeManifest * manifest
Definition: tree_node.h:87
BT::TreeNode::getInput
Expected< T > getInput(const std::string &key) const
Definition: tree_node.h:257
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:438
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:75
BT::TreeNodeManifest::metadata
KeyValueVector metadata
Definition: tree_node.h:40
BT::assignDefaultRemapping
void assignDefaultRemapping(NodeConfig &config)
Definition: tree_node.h:603
BT::NodeConfig::post_conditions
std::map< PostCond, std::string > post_conditions
Definition: tree_node.h:98
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:404
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:394
BT::TreeNode::fullPath
const std::string & fullPath() const
Definition: tree_node.cpp:341
BT::hasNodeNameCtor
constexpr bool hasNodeNameCtor()
Definition: tree_node.h:105
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:166
BT::NodeConfig::output_ports
PortsRemapping output_ports
Definition: tree_node.h:85
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:73
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:81
BT::ControlNode
Definition: control_node.h:21
BT::TreeNode::StatusChangeCallback
StatusChangeSignal::CallableFunction StatusChangeCallback
Definition: tree_node.h:163
BT::NodeStatus
NodeStatus
Definition: basic_types.h:33
script_parser.hpp
BT::TreeNode::stripBlackboardPointer
static StringView stripBlackboardPointer(StringView str)
Definition: tree_node.cpp:401


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Dec 13 2024 03:19:17