Skip to content

Root blackboard missing from generateBlackboardsDump #1130

@BlaiseLebreton

Description

@BlaiseLebreton

Describe the bug
When using a root blackboard, the entries are not visible in Groot2
It would be useful to visualize this blackboard

How to Reproduce
Use a blackboard and @keys

auto blackboard = BT::Blackboard::create();
auto factory = new BT::BehaviorTreeFactory();
BT::Blackboard::Ptr maintree_bb = BT::Blackboard::create(blackboard);
factory.registerBehaviorTreeFromFile("my_bt.xml");
factory.createTree("MainTree", maintree_bb)

Fix
The generateBlackboardsDump nevers exports the root blackboard ?
Adding this in groot2_publisher.cpp:546 works, but it's far from ideal

std::vector<uint8_t> Groot2Publisher::generateBlackboardsDump(const std::string& bb_list)
{
  auto json = nlohmann::json();
  auto const bb_names = BT::splitString(bb_list, ';');
  for(auto name : bb_names)
  {
    std::string const bb_name(name);
    auto it = _p->subtrees.find(bb_name);

    if(it != _p->subtrees.end())
    {
      // lock the weak pointer
      if(auto subtree = it->second.lock())
      {
        json[bb_name] = ExportBlackboardToJSON(*subtree->blackboard);
        json["ROOT"] = ExportBlackboardToJSON(*subtree->blackboard->rootBlackboard());
      }
    }
  }
  return nlohmann::json::to_msgpack(json);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions