BehaviorTree
Core Library to create and execute Behavior Trees
Loading...
Searching...
No Matches
BT::FileLogger2 Class Reference

The FileLogger2 is a logger that saves the tree as XML and all the transitions. Data is written to file in a separate thread, to minimize latency. More...

#include <bt_file_logger_v2.h>

Inheritance diagram for BT::FileLogger2:
Collaboration diagram for BT::FileLogger2:

Classes

struct  Transition
 

Public Member Functions

 FileLogger2 (const Tree &tree, std::filesystem::path const &filepath)
 To correctly read this log with Groot2, you must use the suffix ".btlog". Constructor will throw otherwise.
 
 FileLogger2 (const FileLogger2 &other)=delete
 
FileLogger2operator= (const FileLogger2 &other)=delete
 
 FileLogger2 (FileLogger2 &&other)=delete
 
FileLogger2operator= (FileLogger2 &&other)=delete
 
void callback (Duration timestamp, const TreeNode &node, NodeStatus prev_status, NodeStatus status) override
 
void flush () override
 
- Public Member Functions inherited from BT::StatusChangeLogger
 StatusChangeLogger (TreeNode *root_node)
 Construct and immediately subscribe to status changes.
 
 StatusChangeLogger (const StatusChangeLogger &other)=delete
 
StatusChangeLoggeroperator= (const StatusChangeLogger &other)=delete
 
 StatusChangeLogger (StatusChangeLogger &&other)=delete
 
StatusChangeLoggeroperator= (StatusChangeLogger &&other)=delete
 
virtual void callback (BT::Duration timestamp, const TreeNode &node, NodeStatus prev_status, NodeStatus status)=0
 
virtual void flush ()=0
 
void setEnabled (bool enabled)
 
void setTimestampType (TimestampType type)
 
bool enabled () const
 
bool showsTransitionToIdle () const
 
void enableTransitionToIdle (bool enable)
 

Additional Inherited Members

- Protected Member Functions inherited from BT::StatusChangeLogger
 StatusChangeLogger ()=default
 Default constructor for deferred subscription. Call subscribeToTreeChanges() when ready.
 
void subscribeToTreeChanges (TreeNode *root_node)
 Subscribe to status changes. Call at end of constructor for deferred subscription.
 

Detailed Description

The FileLogger2 is a logger that saves the tree as XML and all the transitions. Data is written to file in a separate thread, to minimize latency.

Format:

  • first 4 bytes: size of the XML string (N)
  • next N bytes: string containing the XML representing the tree.
  • next 8 bytes: first timestamp (microseconds since epoch)
  • next: each 9 bytes is a FileLogger2::Transition. See definition.

Constructor & Destructor Documentation

◆ FileLogger2()

BT::FileLogger2::FileLogger2 ( const Tree tree,
std::filesystem::path const &  filepath 
)

To correctly read this log with Groot2, you must use the suffix ".btlog". Constructor will throw otherwise.

Parameters
treethe tree to log
filepathpath of the file where info will be stored

Member Function Documentation

◆ callback()

void BT::FileLogger2::callback ( Duration  timestamp,
const TreeNode node,
NodeStatus  prev_status,
NodeStatus  status 
)
overridevirtual

◆ flush()

void BT::FileLogger2::flush ( )
overridevirtual

The documentation for this class was generated from the following file: