You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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>intmain(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();
return0;
}
This works:
#include<behaviortree_cpp/bt_factory.h>intmain(int argc, char ** argv)
{
BT::BehaviorTreeFactory factory;
factory.registerBehaviorTreeFromFile("/path/to/my_tree.xml");
auto tree = factory.createTree("MyTree");
auto status = tree.tickWhileRunning();
return0;
}
The text was updated successfully, but these errors were encountered:
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:当我从 XML 文件中包含自定义子树(在本示例中称为MyTree )时,当我将根树内联指定为字符串时,它不起作用。它抛出以下错误:
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.但是,当我直接创建相同的子树或将其包含在从 XML 文件加载的另一棵树中时,一切正常。
How to Reproduce 如何重现
This fails: 这失败了:
#include<behaviortree_cpp/bt_factory.h>intmain(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();
return0;
}
This works: 这有效:
#include<behaviortree_cpp/bt_factory.h>intmain(int argc, char ** argv)
{
BT::BehaviorTreeFactory factory;
factory.registerBehaviorTreeFromFile("/path/to/my_tree.xml");
auto tree = factory.createTree("MyTree");
auto status = tree.tickWhileRunning();
return0;
}
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?
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?
Obviously this is a toy example. A definition of MyTree could look like this:
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: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:
This works:
The text was updated successfully, but these errors were encountered: