-
Notifications
You must be signed in to change notification settings - Fork 745
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When I include a custom subtree (called MyTree
in this example) from an XML file, it does not work when I specify my root tree inline as string. It throws the following error:
terminate called after throwing an instance of 'std::runtime_error'
what(): Can't find a tree with name: MyTree
However, when I create that same subtree directly or when I include it in another tree that I load from an XML file, everything works fine.
How to Reproduce
This fails:
#include <behaviortree_cpp/bt_factory.h>
int main(int argc, char ** argv)
{
BT::BehaviorTreeFactory factory;
factory.registerBehaviorTreeFromFile("/path/to/my_tree.xml");
std::string tree_xml =
R"(
<root BTCPP_format="4" >
<BehaviorTree ID="TestTree">
<SubTree ID="MyTree"/>
</BehaviorTree>
</root>)";
auto tree = factory.createTreeFromText(tree_xml);
auto status = tree.tickWhileRunning();
return 0;
}
This works:
#include <behaviortree_cpp/bt_factory.h>
int main(int argc, char ** argv)
{
BT::BehaviorTreeFactory factory;
factory.registerBehaviorTreeFromFile("/path/to/my_tree.xml");
auto tree = factory.createTree("MyTree");
auto status = tree.tickWhileRunning();
return 0;
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
Aglargil commentedon Nov 1, 2024
It looks like it's because you didn't define SubTree, I tried to use your second way and still got the error, can you provide the /path/to/my_tree.xml?
tropappar commentedon Nov 1, 2024
Obviously this is a toy example. A definition of MyTree could look like this: