Closed
Description
Hi, I'm using BehaviorTree.cpp version 4.0.1
I can successfully use the _skipIf
precondition to avoid ticking some "standard nodes", but it seems to be ignored by the SubTree
s.
I suspect that the reason has to do with the fact that subtrees forward their arguments to the children nodes for remapping
See example
class DoSomething : public BT::SyncActionNode
{
public:
DoSomething(const std::string& name, const BT::NodeConfig& config)
: BT::SyncActionNode(name, config)
{ }
static BT::PortsList providedPorts()
{
return { };
}
BT::NodeStatus tick() override
{
std::cout << "Hello world "<< std::endl;
return BT::NodeStatus::SUCCESS;
}
};
int main()
{
auto my_factory = std::make_unique<BT::BehaviorTreeFactory>();
my_factory->registerNodeType<CheckFloat>("CheckFloat");
std::stringstream bt_tree_text;
bt_tree_text << R"(
<root BTCPP_format="4">
<BehaviorTree ID="MySubTree">
<Sequence>
<Action ID="DoSomething"/>
</Sequence>
</BehaviorTree>
<BehaviorTree ID="MainTree">
<Sequence>
<Script code=" data:=true "/>
<SubTree ID="MySubTree" _skipIf="data"/>
</Sequence>
</BehaviorTree>
</root>)";
my_factory->registerBehaviorTreeFromText(bt_tree_text.str());
auto tree = my_factory->createTree("MainTree");
tree.tickWhileRunning();
return 0;
}