23 const BT::Tree & tree,
const rclcpp::Logger & node_logger, std::chrono::seconds max_logging_interval)
24: StatusChangeLogger{tree.rootNode()},
26 root_tree_id_{tree.subtrees[0]->tree_ID},
27 max_logging_interval_{max_logging_interval}
45 BT::Duration timestamp,
const BT::TreeNode & node, BT::NodeStatus prev_status, BT::NodeStatus status)
47 if (node.type() == BT::NodeType::ACTION && status == BT::NodeStatus::RUNNING) {
48 auto name = node.registrationName() == node.name() ? node.name() : node.registrationName() +
": " + node.name();
49 running_action_history_.push_back(name);
50 last_running_action_name_ = name;
57 if (!logging_active_)
return;
58 const auto key = std::make_pair(node.UID(), createStateChangeBitmask(prev_status, status));
59 const bool is_first_log = last_log_map_.count(key) == 0;
61 if (is_first_log || timestamp - last_log_map_[key] > max_logging_interval_) {
62 if (node.registrationName() == node.name()) {
64 logger_,
"[%s] %s '%s' -- %s -> %s", root_tree_id_.c_str(), BT::toStr(node.type()).c_str(), node.name().c_str(),
65 BT::toStr(prev_status,
true).c_str(), BT::toStr(status,
true).c_str());
68 logger_,
"[%s] %s '%s: %s' -- %s -> %s", root_tree_id_.c_str(), BT::toStr(node.type()).c_str(),
69 node.registrationName().c_str(), node.name().c_str(), BT::toStr(prev_status,
true).c_str(),
70 BT::toStr(status,
true).c_str());
72 last_log_map_[key] = timestamp;