bt_cout_logger.cpp
Go to the documentation of this file.
2 
3 namespace BT
4 {
5 
7 {}
9 {}
10 
11 void StdCoutLogger::callback(Duration timestamp, const TreeNode& node,
12  NodeStatus prev_status, NodeStatus status)
13 {
14  using namespace std::chrono;
15 
16  constexpr const char* whitespaces = " ";
17  constexpr const size_t ws_count = 25;
18 
19  double since_epoch = duration<double>(timestamp).count();
20  printf("[%.3f]: %s%s %s -> %s", since_epoch, node.name().c_str(),
21  &whitespaces[std::min(ws_count, node.name().size())],
22  toStr(prev_status, true).c_str(), toStr(status, true).c_str());
23  std::cout << std::endl;
24 }
25 
27 {
28  std::cout << std::flush;
29 }
30 
31 } // namespace BT
BT
Definition: ex01_wrap_legacy.cpp:29
BT::StdCoutLogger::~StdCoutLogger
~StdCoutLogger() override
Definition: bt_cout_logger.cpp:8
BT::StdCoutLogger::flush
virtual void flush() override
Definition: bt_cout_logger.cpp:26
BT::TreeNode
Abstract base class for Behavior Tree Nodes.
Definition: tree_node.h:118
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::StdCoutLogger::callback
virtual void callback(Duration timestamp, const TreeNode &node, NodeStatus prev_status, NodeStatus status) override
Definition: bt_cout_logger.cpp:11
BT::StatusChangeLogger
Definition: abstract_logger.h:15
BT::Duration
std::chrono::high_resolution_clock::duration Duration
Definition: basic_types.h:628
BT::StdCoutLogger::StdCoutLogger
StdCoutLogger(const BT::Tree &tree)
Definition: bt_cout_logger.cpp:6
bt_cout_logger.h
BT::TreeNode::name
const std::string & name() const
Name of the instance, not the type.
Definition: tree_node.cpp:302
BT::NodeStatus
NodeStatus
Definition: basic_types.h:33
BT::toStr
std::string toStr(const T &value)
toStr is the reverse operation of convertFromString.
Definition: basic_types.h:252


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