Skip to content

How to get a list of the Blackboard keys from a node? #188

@lstelzner

Description

@lstelzner

I'm creating a class that inherits from BT::StatusChangeLogger . In this class I want to collect extra data including what is currently in the nodes' Blackboard (keys/values) at the time of the callback function. Since my tree has multiple nodes with various input and output ports, I do not know the key strings from within callback. I've been trying the following but it crashes once it reaches getKeys() .

void Metrics::callback(BT::Duration timestamp, const BT::TreeNode& node,
                              BT::NodeStatus prev_status, BT::NodeStatus status)
{
 
  BT::Blackboard::Ptr bb(node.config().blackboard);
  if (!bb )
  { 
    ROS_WARN("Getting keys");
    std::vector<BT::StringView> keys = bb->getKeys();
  ROS_WARN("GOT Keys");
  }
}  
[ WARN] [1588786259.942270451, 1588786258.704000000]: Getting keys
[behavior-1] process has died [pid 127, exit code -11, cmd ...behavior_trees_node __name:=behavior

In running in a debugger an exception happens on out.reserve( storage_.size() );

out.reserve( storage_.size() );

Leading me to suspect maybe my method of getting the blackboard is incorrect.
Is what I want to do supported by the API, and if so what is the correct way to do it?
Thanks.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions