-
Notifications
You must be signed in to change notification settings - Fork 821
Script error with boolean operator on subtree input #1122
Copy link
Copy link
Open
Description
Describe the bug
Hello,
It seems like subtrees inputs that are boolean are interpreted as strings in the subtree scripts.
How to Reproduce
With this code :
#include <behaviortree_cpp/behavior_tree.h>
#include <behaviortree_cpp/bt_factory.h>
#include <print>
constexpr auto print_hello(const BT::TreeNode &node) {
std::println("hello world");
return BT::NodeStatus::SUCCESS;
}
int main(int argc, char *argv[]) {
auto tree = [] {
BT::BehaviorTreeFactory factory;
factory.registerSimpleAction("PrintHello", print_hello);
factory.registerBehaviorTreeFromFile("./scripting.xml");
return factory.createTree("Main");
}();
auto bb = tree.rootBlackboard();
tree.tickWhileRunning();
return 0;
}And this tree :
<?xml version="1.0" encoding="UTF-8"?>
<root BTCPP_format="4">
<BehaviorTree ID="Main">
<SubTree ID="MaybePrintHello"
do_print="true"/>
</BehaviorTree>
<BehaviorTree ID="MaybePrintHello">
<PrintHello _skipIf="!do_print"/>
</BehaviorTree>
<!-- Description of Node Models (used by Groot) -->
<TreeNodesModel>
<SubTree ID="MaybePrintHello"
editable="true">
<input_port name="do_print"
type="bool"/>
</SubTree>
<Action ID="PrintHello"
editable="true"/>
</TreeNodesModel>
</root>We get the following exception :
Exception in node 'MaybePrintHello::1' [SubTree]: Error in script [!do_print]
Invalid operator for std::string
I tried with do_print == true and I don't get the exception, but "hello world" is not printed.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels